您的位置:首页 > 数据库 > Oracle

oracle 自增列 & 创建表空间

2013-07-11 16:57 239 查看
一 建序列
create sequence squence_name
  increment by 1 --按1增长
  start with 1 --从1开始
  nomaxvalue --不设最大值
  nocycle  --不循环
  cache 10; --缓冲

create sequence seq_fxc_tsxx_vio_xh increment by 1--按1增长
start with 1--从1开始
nomaxvalue nocycle cache 10;
二 相应表上建触发器应用序列
create or replace trigger trigger_name
before insert on tableName
for each row
begin
select squence_name.nextval into :new.id from dual; --:new.id id 为需要自增的列
end;

-------------------------------------------------------------创建表空间

create tablespace tsName datafile 'd:\??.dbf'
size 10M autoextend
on next 10M maxsize
unlimited

-------------------------------------------------------------查看当前用户表空间
select username,default_tablespace from user_users;

-------------------------------------------------------------查看当前用户表空间路径

select * from dba_data_files where tablespace_name = '表空间名区分大小写'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: