Oracle使用动态sql语句创建用户报错:ORA-00922: 选项缺失或无效
DECLARE
pmajorno VARCHAR2(512);
BEGIN
FOR pmajorno IN (SELECT DISTINCT majorno FROM major)
LOOP
dbms_output.put_line('CREATE USER major'|| pmajorno.majorno||' INDENTIFIED BY admin'|| pmajorno.majorno);
EXECUTE IMMEDIATE 'CREATE USER major' ||pmajorno.majorno||' INDENTIFIED BY admin' ||pmajorno.majorno;
END LOOP;
END;
运行结果及报错内容
报错(其中输出了一行):
在行 1 上开始执行命令时出错:
DECLARE
pmajorno VARCHAR2(512);
BEGIN
FOR pmajorno IN (SELECT majorno FROM major)
LOOP
dbms_output.put_line('CREATE USER major'|| pmajorno.majorno||' INDENTIFIED BY admin'|| pmajorno.majorno);
EXECUTE IMMEDIATE 'CREATE USER major'||pmajorno.majorno||' INDENTIFIED BY admin'||pmajorno.majorno;
END LOOP;
END;
错误报告:
ORA-00922: 选项缺失或无效
ORA-06512: 在 line 7
00922. 00000 - "missing or invalid option"
*Cause:
*Action:
CREATE USER major01 INDENTIFIED BY admin01
我的解答思路和尝试过的方法
把execute语句删除后是可以正常输出创建用户语句的,但是加上后就一直报错,对于ORA-00922:单独去创建用户时语句内容正确的,即不是用户名或者密码不合法;对于ORA-06512:说是缓存大小超出了,所以设置变量为VARCHAR(512),但还是报错。求解答