drop table book;
drop sequence book_seq;
drop trigger book_tri;
--創建表格
create table book
(
bookId integer primary key not null,
bookName varchar2(20),
price number(3)
)tablespace zfs_data
desc book;
--創建序列
--創建一個從10000開始每次遞增為1的序列
create sequence book_seq minvalue 10000 maxvalue 9999999 increment by 1 start with 10000 ;
--創建一個觸發器,用于每次插入前自動成成序列的值
create or replace trigger book_tri
before insert on book for each row
begin
select book_seq.nextval into :new.bookId from dual;
end;
/
commit;
insert into book (bookName, price) values('深入淺出EXTJS',59);
insert into book (bookName, price) values('深入淺出Jquery',49);
select * from book;