创建表的完整语法,基本数据类型, 枚举与集合类型,约束条件
创建表的完整语法 create table 表名( 字段名1 类型[(宽度) 约束条件], 字段名2 类型[(宽度) 约束条件], 字段名3 类型[(宽度) 约束条件] ); 注意: 1.字段名和字段类型是必须的 中括号内的参数都是可选参数 2.同一张表中字段名不能重复 3.最后一个字段后面不能加逗号 create table t6( id int, name char, ); 宽度: 使用数据库的准则:能尽量让它少干活就尽量少干活 对存储数据的限制 char(1) 只能存一个字符 如果超了 mysql会自动帮你截取 1.插入的时候 mysql自动截取 2.会直接报错(mysql严格模式) alter table t5 modify name char not null; not null该字段不能插空 create table t1(id int)engine=innodb; create table t2(id int)engine=myisam; create table t3(id int)engine=memory; create table t4(id int)engine=blackhole; insert into t1 values(1); insert into t2 values(2); insert into t3 values(3); insert