mysql 修改数据库表结构

  1. 增加约束条件 alter table [表名] add constraint [约束];
       如alter table users add constraint primary key(username,birthdate);
  2. 去掉约束条件 alter table [表名] drop PRIMARY KEY | INDEX | FOREIGN KEY;
  3. 修改列类型 alter table [表名] modify column [列名] [新类型];
  4. 增加列 alter table [表名] add column [列名] [新类型] [列级约束] ;
    如alter table users add column id int auto_increment primary key;
  5. 修改原来的某列为自增主键。alter table [表名] modify column [主键列名]  int(10)  auto_increment primary key;
posted @ 2011-12-13 16:52  tazi  阅读(236)  评论(0编辑  收藏  举报