MySQL数据库的约束

2023-05-07  本文已影响0人  大龙10

一、 MySQL数据类型

常用的数据类型有:

二、约束

1、为什么需要约束

2、什么是约束

3、如何指定自增约束

create table test
(
id int(10) not null auto_increment, -- 表示自增列
name varchar(20) not null,
primary key(id)
)
auto_increment = 1; -- 表示自增起始大小-- 这样就可以创建一个表test,id为自增列
-- 执行语句 insert into test (name) values ('名字');
-- 就可以插入一行数据为: 1 '名字'

上一篇 下一篇

猜你喜欢

热点阅读