LoginSignup
1
0

More than 5 years have passed since last update.

MySQL コマンドメモ

Last updated at Posted at 2017-04-25
  • 使用するDBを選択
    use データベース名

  • DB内のテーブル一覧
    show tables;
    もしくは
    show tables from データベース名;

  • テーブル内のカラム型やデフォルト値等を確認
    desc テーブル名;

  • カラムの追加
    alter table テーブル名 add 新カラム名 カラム型;

  • カラムの削除
    alter table テーブル名 drop column カラム名;

  • カラムを指定した位置に移動
    (カラムAのうしろにカラムBを移動)
    alter table テーブル名 modify カラムB カラム型 after カラムA;

  • カラム型の変更
    alter table テーブル名 modify カラム名 データ型;

  • 結合された2つのDBの差分抽出
    select * from テーブル1 as w right join テーブル2 as t on w.カラム名 == t.カラム名;

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0