标签:select rem 系统默认 check key dual 查询 acl sel
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥-------------
create table student(
sno number(4) not null,
sname varchar2(10) not null,
birthdday date
);
alter table student add(sal number(7,2),wechat varchar2(20));
alter table student modify(sname varchar2(20));
alter table student add(sax char(2));
alter table student rename column sax to sex;
alter table student add constraint pk_student_sno primary key(sno);
alter table student add constraint uk_student_sname unique(sname);
alter table student add constraint ck_student_sex check(sex in(‘男‘,‘女‘));
alter table student add(gid number(4));
create table grade(
gradeId number(4) not null primary key,
gradename varchar2(10) not null
);
alter table student add constraint fk_student_grade_gid foreign key (gid)
references grade(gradeId);
------------------------------------------------------
序列有些像mysql的自增列,sqlserver的标识列
create sequence sq_studet_sno --序列的名称
start with 10 --序号的开始数值
increment by 10 --步长 每次序号增长的值
maxvalue 9999999999 --序号的最大值
cycle --nocycle 达到最大值时是否重新开始循环序列号
cache 20 --是否缓存序列号,默认是20个,假如步长是10,缓存20就是200个数,可以用nocache
rename sq_student_no to sq_student_sno
select * from user_sequences;
select sq_student_sno.nextval from dual;
select sq_student_sno.currval from dual;
insert into grade(gradeid,gradename)
values(sq_student_sno.nextval,‘三年级‘);
select * from grade;
标签:select rem 系统默认 check key dual 查询 acl sel
原文地址:https://www.cnblogs.com/DawnCHENXI/p/9005137.html