关键字: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

    1. create table table1 -- 创建的表必须是不存在的表
    2. (
    3. column1 int not NULL auto_increment, -- not NULL表示此列不能有NULL
    4. column2 char(50) not NULL,
    5. column3 char(5) NULL default 'A',
    6. column4 char(255) NULL,
    7. primary key (column1)
    8. ) engine=InnoDB;
    9. alter table table1 add column2 char(20);
    10. alter table table1 drop column2;
    11. drop table table1;
    12. rename table table1 to table2;
    13. rename table table1 to table2,table3 to table4,...;