create table my_table
(
ID NUMBER(10) not null,
BUYER CHAR(20) not null,
MERCHANDISE VARCHAR2(50) not null,
QUANTITY LONG not null,
UNITPRICE NUMBER(10,2) not null,
TOTALPRICE NUMBER(20,4),
DESCRIPTION NVARCHAR2(1000),
PRIMARY KEY("ID")
)
create or replace trigger 触发器名字
before insert on mytable
for each row
begin
if (:new.id is null) then
select my_table_id_seq.nextval into :new.id from dual;
end if;
end;
4.这样就可以插入不带ID的记录了
insert into mytable(buyer,merchandise,quantity,unitprice)values("ABC","Product_ABC",200,10);