网站建设类的职位,公司网站简历刷新怎么做,如何识别html5网站,挣钱最快的游戏创建Oracle数据库的字段约束#xff1a;非空约束唯一约束对字段的取值的约束默认值外键约束create table tab_class(class_id number primary key,class_name varchar2(10) not null unique);create table tab_stu(stu_id number,--学生姓名#xff0c;不能为空#xff0c;不…创建Oracle数据库的字段约束非空约束唯一约束对字段的取值的约束默认值外键约束create table tab_class(class_id number primary key,class_name varchar2(10) not null unique);create table tab_stu(stu_id number,--学生姓名不能为空不能重复stu_name varchar2(20) not null unique,--学生姓名只能是male或femalestu_gender varchar2(6) not null check(stu_gendermale or stu_genderfemale),--学生年龄只能在18到60之间stu_age number check(stu_age 18 and stu_age 60),--邮箱可以不填写填写的话不能相同stu_email varchar2(30) unique,stu_address varchar2(30),--外键约束class_id number not null references tab_class(class_id));维护已经创建好的约束可添加或删除约束但不能直接修改。可使约束启用和禁用。非空约束必须使用MODIFY子句增加。为表增加主键约束--维护约束--创建约束create table tab_check(che_id number,che_name varchar2(20));--为表增加主键约束alter table tab_checkadd constraints tab_check primary key(che_id);添加唯一约束--添加唯一约束,tab_check_unique表示约束的名称alter table tab_checkadd constraints tab_check_unique unique(che_name);添加检查约束--添加一个字段alter table tab_checkadd che_age number;--添加检查约束alter table tab_checkadd constraints tab_check_age check(che_age18 and che_age60);删除约束--删除主键约束alter table tab_checkdrop constraints tab_check;禁用约束--禁用约束alter table tab_check disable constraints tab_check;启用约束--启用约束alter table tab_check enable constraints tab_check;复合约束联合主键也就是两个字段的组合成一个主键--联合主键create table tab_person(tab_firstname varchar2(10),tab_lastname varchar2(10),tab_gender varchar2(5),primary key(tab_firstname,tab_lastname));为表添加外键约束alter table tab_stuadd constraints tab_stu foreign key(class_id) references tab_class(class_id);以上就是本文的全部内容希望对大家的学习有所帮助也希望大家多多支持脚本之家。