Database constraints define rules for data storage and retrieval.
发布时间
阅读量:
阅读量
目录
1、约束指的是什么?
2、约束涵盖哪些类型?
3、非空限制 not null
4、唯一性限制 unique
5、主键限制(primary key,简称pK)
6、外键限制
1、什么是约束?
约束对应的英文术语为:constraint
在构建数据表的过程中,我们可以通过为字段设置特定限制条件,从而确保表内数据的完整性和准确性!!
这些限制条件的核心目的即在于保障:表中所存储的数据具备有效性!!
2、约束包括哪些?
非空限制:not null
唯一性限制:unique
主键限制:primary key(简称为pK)
外键限制:foreign key(简称为FK)
验证限制:check(在mysql中不被支持,而oracle中则支持)
3、非空约束 not null
非空约束 not null 所限定的字段不允许赋值为 NULL。
drop table if exists t vip;
create table t_vip(
id int,
name varchar (255) not null
);
insert into t vip(id,name) values(1, 'zhangsan') ;
insert into t vip(id,name) values(2,'lisi');
inse
全部评论 (0)
还没有任何评论哟~
