MYSQL操作フィールド

464 ワード

1.フィールドを追加
alter table user add column  user_name varchar(20) not null default 'admin' comment '      '; 

2.フィールドの削除
alter table user drop column  user_name; 

3.フィールドの変更
  • フィールドのタイプを変更する
    alter table user modify user_name varchar(10); 
    
  • フィールド名を変更するには、そのフィールドのタイプ
    alter table user change user_name other_name int;
    
  • を再指定する必要があります.