0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQL: ALTER TABLEの使い方メモ

Last updated at Posted at 2020-04-21

SQLのテーブル定義を変更するalter文の使い方メモ(MySQLで検証)

# テーブル名の変更
alter table target_table rename to new_table;


# カラム名の変更
alter table target_table rename target_column to new_column;


# カラム定義の変更
alter table target_table modify target_column [新しいカラム定義];
## (例)alter table target_table modify target_column varchar(20) default NULL;


# 新しいカラムの追加
alter table target_table add new_column [カラム定義]
## (例)alter table target_table add new_column varchar(20) default NULL;
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?