你没有为id字段指定插入值,所以会报错.使用序列
SQL> create sequence a_seq
2 start with 1
3 increment by 1;序列已创建。
sql>insert into table1 select a_seq.nextval,department,name where name='111';
SQL> create sequence a_seq
2 start with 1
3 increment by 1;序列已创建。
sql>insert into table1 select a_seq.nextval,department,name where name='111';
重点是怎么样用那样的语句写入自动增长的id
具体的方法 tsj68(tsj) 已经做到了。
如果table1的用户name1,而table2的用户是name2,都有相应的权限,那sql语句又应该怎么该?
如果table1的用户name1,而table2的用户是name2,都有相应的权限,那sql语句又应该怎么该?
MAXVALUE 1.0E28 MINVALUE 1 CYCLE
NOCACHE NOORDER;
/
CREATE OR REPLACE TRIGGER table1_tri
BEFORE INSERT ON table1
FOR EACH ROW
BEGIN
SELECT IDno.NEXTVAL INTO :NEW.id FROM DUAL;
END;
/insert into table1(department,name)
select department,name from table2 where name='111';