关键字:create table table_name
主键关键字:primary key (column1,column2,…)
自动增量id(+1):auto_increment,一个表只有一个auto_increment列,必须被索引
指定默认值:default,只可默认常量,不能默认函数值
引擎类型:
- InnoDB:可靠的事务处理引擎,不支持全文本搜素
- MEMORY:功能等同于MyISAM,但由于数据存储在内存(非磁盘),速度很快(适用月临时表)
- MyISAM:性能极高,支持全文本搜素,不支持事务处理
外键不能跨引擎
更新表:alter table table1
- 添加列
- 删除列
删除表:drop table table1
重命名表:rename table table1 to table2
create table table1 -- 创建的表必须是不存在的表(column1 int not NULL auto_increment, -- not NULL表示此列不能有NULL值column2 char(50) not NULL,column3 char(5) NULL default 'A',column4 char(255) NULL,primary key (column1)) engine=InnoDB;alter table table1 add column2 char(20);alter table table1 drop column2;drop table table1;rename table table1 to table2;rename table table1 to table2,table3 to table4,...;
