5 alter 改写历史

来源:互联网 发布:人工智能研究领域包括 编辑:程序博客网 时间:2024/05/17 01:47

alter ---- 改写历史

alter table my_contacts
add column contact_id int not null auto_increment first,
add primary key(contact_id);

alter table my_contacts
add column phone varchar(10)
after fistname;
========
after 是可选关键字,如果不使用它,新列则会添加至表的最后


更改表名
alter table projekts
rename to projekts_list;

更改列名,并设置列的属性
alter table project_list
change column number proj_id int not null auto_increment,
add primary key(proj_id);


更改列的属性
alter table projcet_list
modify column proj_dec varchar(120);


卸载列
alter table project_list
drop column start_date;

0 0
原创粉丝点击