7.カラムを操作する

■カラムの追加
mysql>alter table テーブル名 add カラム名 データ型;
例)mysql> alter table ex_table add ex_c_new int;

■カラム名の変更
mysql> alter table テーブル名 change カラム名(現在) カラム名(新) データ型;
例)mysql> alter table ex_table change ex_c ex_c_new varchar(30);

■カラム定義の変更
mysql> alter table テーブル名 change カラム名 カラム名 新たな定義;
例)mysql> alter table ex_table change ex_c ex_c int;

■カラムの削除
mysql> alter table テーブル名 drop カラム名;
例)mysql> alter table ex_table drop ex_c;

戻る | CGI'sトップへ戻る