如何在Oracle中一次执行多条sql语句

2024-11-05 22:47:06
推荐回答(3个)
回答(1):

写个plsql 代码块,把insert语句包起来就可以了,参考:
BEGIN
DELETE FROM SYSROLEOPENR WHERE ROLEID = 2;
INSERT INTO SYSROLEOPENR
(PKID, ROLEID, OPERID)
SELECT SYSROLEOPENR_PKID_SEQ.NEXTVAL, '2' ROLEID, OPERID
FROM SYSMODULEOPER
WHERE OPERCODE = '300090010';
INSERT INTO SYSROLEOPENR
(PKID, ROLEID, OPERID)
SELECT SYSROLEOPENR_PKID_SEQ.NEXTVAL, '2' ROLEID, OPERID
FROM SYSMODULEOPER
WHERE OPERCODE = '300090020';
INSERT INTO SYSROLEOPENR
(PKID, ROLEID, OPERID)
SELECT SYSROLEOPENR_PKID_SEQ.NEXTVAL, '2' ROLEID, OPERID
FROM SYSMODULEOPER
WHERE OPERCODE = '300090050';
END;

回答(2):

1、将你要执行的sql语句写入一个txt文件中; 2、修改文件后缀为.sql文件; 3、使用 “source + 路径+文件名” 注:source与路径之间有空格。

回答(3):

写sql脚本,原后@那个脚本就行了!