sequence 序列
作用:创建主键,可以自增
生成主键的序列号
create sequence 序列名
increment by 步长,就是序列之间的间隔
start with 开始值
maxvalue 最大值
minvalue 最小值
cache 缓存
cycle 循环
drop sequence tea_seq;
create sequence tea_seq
start with 4;
naxtval:下一个值
currval :当前值
刚创建时,不能直接差currval值,必须先差nexval
select tea_seq.nextval from dual
select tea_seq.currval from dual
alter table tea
modify tid number
insert into tea values(
tea_seq.nextval,'pyhon',1104);
视图 view:以个查询出来的表
好处:简化查询,限制权限
create view 视图名
as select 查询语句
alter table ydd
rename column name to first_name
--权限不足 (此处需要注意)
create view tea_ydd
as select t.id,t.name,y.first_name
from tea t,ydd y
where t.id!=y.first_id
查询tea_ydd表
索引:index 提高效率
b_tree类似二叉树
系统会自己去检查是否有索引,有的话会根据索引去查找
create index 索引名字
on 表名(列)
此列表已索引
create index firstindex
on tea(id);
作用:创建主键,可以自增
生成主键的序列号
create sequence 序列名
increment by 步长,就是序列之间的间隔
start with 开始值
maxvalue 最大值
minvalue 最小值
cache 缓存
cycle 循环
drop sequence tea_seq;
create sequence tea_seq
start with 4;
naxtval:下一个值
currval :当前值
刚创建时,不能直接差currval值,必须先差nexval
select tea_seq.nextval from dual
select tea_seq.currval from dual
alter table tea
modify tid number
insert into tea values(
tea_seq.nextval,'pyhon',1104);
视图 view:以个查询出来的表
好处:简化查询,限制权限
create view 视图名
as select 查询语句
alter table ydd
rename column name to first_name
--权限不足 (此处需要注意)
create view tea_ydd
as select t.id,t.name,y.first_name
from tea t,ydd y
where t.id!=y.first_id
查询tea_ydd表
索引:index 提高效率
b_tree类似二叉树
系统会自己去检查是否有索引,有的话会根据索引去查找
create index 索引名字
on 表名(列)
此列表已索引
create index firstindex
on tea(id);