LoginSignup
1
0

More than 5 years have passed since last update.

MySQLでよく検索してしまうコマンド

Last updated at Posted at 2019-06-01

個人的なメモ集ですが、宜しければどうぞ。
間違っていたらごめんなさい。
随時追加しつつ、見なくても打てるようになったらいいなあ。

SQL

//user_t,gaibu_t...テーブル名
//userID,itemNo...カラム名

//新規テーブル作成時のPRIMARY KEY(主キー)と外部キーの設定
CREATE TABLE user_t(userID int,itemNo int,
                    PRIMARY KEY(userID),//主キー設定
                    FOREIGN KEY(itemNo)//外部キー
                    REFERENCES gaibu_t(itemNo))//テーブルとカラム名

//PRIMARY KEY(主キー)の追加設定
ALTER TABLE user_t ADD PRIMARY KEY(userID);

//AUTO_INCREMENTの追加設定
ALTER TABLE user_t CHANGE userID userID int AUTO_INCREMENT;

//テーブル名の変更
ALTER TABLE old_t RENAME TO new_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