1 创建一张表,要求包含:主键约束,非空约束,唯一约束;然后插入数据测试3种约束的特点(截图展示结果)
主键约束
create table test(
id int primary key ,
name varchar(40) not null,
address varchar(200) unique
);
insert into test(id,name,address) values (1,"秦羽","秦氏修仙家族");
insert into test(id,name,address) values (1,"张飞","张氏屠夫家族");
insert into test(id,name,address) values ("null","涵灵儿","涵氏修仙家族");
非空约束
insert into test(id,name,address) values (2,"林动","林氏修仙家族");
insert into test(id,name,address) values (3,null,"某某家族");
唯一约束
insert into test(id,name,address) values (3,"云中君","云氏峡谷家族");
insert into test(id,name,address) values (4,"云中鸟","云氏峡谷家族");