r table Student
add constraint CK_stuBornDate check (BornDate >= '1980-01-01')
--添加外键约束(主表Student和从表Result建立关系,关联列为StudentNo)
alter table Result
add constraint FK_stuNo
foreign key (stuNo) references Student(stuNo)
www.2cto.com
--删除约束:
alter table 表名
drop constraint 约束名
-----------------------序列------------------------------------
/*创建序列,序列用来为表的主键生成唯一的序列值.
可选参数:
Increment by 指定序列值每次增长的值
Start with 指定序列的第一个值
Maxvalue 指定产生的序列的最大值
Minvalue 指定产生的序列的最小值
Cycle 指定当序列值逵到最大或最小值时,该序列是否循环.
Cache 指定序列生成器一次缓存的值的个数
Order 指定序列中的数值是否按访问顺序排序.
*/
create sequence 序列名
increment by 4
start with 50
maxvalue 60
minvalue 50
cycle
cache 3;
www.2cto.com
--查看序列,dual为虚拟表
select 序列名.nextval from dual;
select 序列名.currval from dual;
-----------------------column命令简单使用--------------------------------------
--使用column命令格式化指定的列(以emp表为例)
column empon heading '员工编号' format 9999;
column ename heading '员工姓名' format a10;
column mgr heading '上级编号' format 9999;
column hiredate heading '受雇日期' justify center;
column sal heading '员工工资' format $999,999,99;
select * from emp;