在plsql中我创建了一张 ccc_points_report 表,哪位大侠知道给这张表添加序列该如何写 ?我是要进行插入操作 主键唯一的那种,好像还有个触发器这样的。一时想不起来怎么写了?请大家给小弟救急救急,万分感谢!!!
解决方案 »
- 同事问我,MySql和Oracle里面,可能分库的查询表,是用自增字段好还是Guid字段好。查询大于新增、修改。
- with a as 缺失select 关键字
- 如何用rman进行自动备份呢?急、急、急
- sqlserver2000存储过程如何改为oracle存储过程?
- ◆发生了ORA-02063问题
- 无法describe一个表
- 请问如何执行多个dml文件中的sql语句?
- 如何提高速度
- 很大的String型,如何存入clob对象?
- 分布式数据库得一致性维护是通过什么机制来实现得阿?
- 求SQL语句 case when 对时间字段的使用?
- CROSSCHECK BACKUP与CROSSCHECK BACKUPSET的区别是啥呢
create sequence ccc_points_seq
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 20;在表中把你的id设为主建
[start with start_num]
[increment by increment_num]
[{ maxvalue maximum_num | nonmaxvalue}]
[{ minvalue minimum_num | nonminvalue }]
[{ cycle | nocycle }]
[{ cache cache_num | nocache } ]
[{ order | noorder } cache – 指定要保留在内存中整数的个数,默认为20
最少为2个,
最多为cell( maximum_num – minimum_num)/abs(increment_num)
create or replace trigger set_seq
before insert of test1
for each row
declare
sn number(5);
begin
select seq.nextval into sn from dual;
:new.id=sn;
end;把这个触发器写到你需要这个序列的表中,把表明和序列名字修改下就好了!
往表时插入数据里,用nextval 直接取序列的下一个值。