强迫自己学点儿Oracle:-)

反正数据库作业也是要做的,索性Oracle吧~

今天被Oracle整郁闷了

1、表名默认是大写,如果你像我一样自作聪明改成了小写,那么所有的表要加引号……

2、没有自动递增,可以用一个序列+一个触发器来搞。。。这个更郁闷我,弄了2小时。。。

序列:
CREATE SEQUENCE "JIUDIAN"."ROOM_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE

触发器:

declare
nextnum number;
BEGIN
if :NEW."roomID" is null or :NEW."roomID"=0 then
select "ROOM_SEQ".nextval into nextnum from sys.dual;
:NEW."roomID":=nextnum;
end if;
END;
 

Leave a Reply

Your email address will not be published. Required fields are marked *