![](https://img.haomeiwen.com/i18938642/d8a38cbfa7e0f0d1.png)
![](https://img.haomeiwen.com/i18938642/6f32c39419cf0aa9.png)
CREATE TABLE class (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(10) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
是否可空,null表示空,并不是字符串类型
not null - 不可空,在添加数据时必须给值
null - 可空(这是非主键的默认属性)
自增,如果为某列设置自增列,插入数据时无需设置此列的值,默认将自增(表中只能有一个自增列)
create table 表名(
id int auto_increment primary key,
age int not null
)
创建表时可以单独指定其使用的存储引擎和默认字符编码。
ENGINE=InnoDB DEFAULT CHARSET=utf8
char 固定字符串 varchar 可变字符串
Enum 枚举 只选一个值
SET 集合 选多个值
存储引擎 InnoDB (原子性,一致性,隔离,持久性)
![](https://img.haomeiwen.com/i18938642/b34a57d73b8d7ca8.png)
![](https://img.haomeiwen.com/i18938642/3a6a56666872a27f.png)
![](https://img.haomeiwen.com/i18938642/2b55bbc75b790fd2.png)
![](https://img.haomeiwen.com/i18938642/0f28e148409d51e3.png)
![](https://img.haomeiwen.com/i18938642/56271f63044e9f17.png)
![](https://img.haomeiwen.com/i18938642/38892de676dca0fc.png)
![](https://img.haomeiwen.com/i18938642/736b2cba3c276dbd.png)
![](https://img.haomeiwen.com/i18938642/d00b533f4270b4a3.png)
![](https://img.haomeiwen.com/i18938642/6425fe0b638e1e28.png)
网友评论