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

2024年11月05日 22:47
有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脚本,原后@那个脚本就行了!