我想在oracle中創建用戶,使用我現有的表調用EMPLOYEE,我想生成一個查詢來創建用戶名和用戶。用戶名在EMPLOYEE表中。Oracle查詢內部查詢
我想創建像下面
CREATE USER (SELECT first_name FROM employee where employee_id = '1')
IDENTIFIED BY password .....so on
我想在oracle中創建用戶,使用我現有的表調用EMPLOYEE,我想生成一個查詢來創建用戶名和用戶。用戶名在EMPLOYEE表中。Oracle查詢內部查詢
我想創建像下面
CREATE USER (SELECT first_name FROM employee where employee_id = '1')
IDENTIFIED BY password .....so on
DBMS_UTILITY.EXEC_DDL_STATEMENT可以用來在運行PLSQL DDL語句,所以你可以試試下面的
BEGIN
FOR c IN (select 'CREATE USER ' || first_name || ' ' || 'IDENTIFIED BY ' ||
password_column ||' ' as rec
from employee where employee_id=1) LOOP
begin
dbms_utility.exec_ddl_statement(c.rec);
exception
when others then
dbms_output.enable;
dbms_output.put_line ('failed for '||c.rec);
dbms_output.put_line(sqlerrm);
end;
END LOOP;
END;
心靈更多的細節展開這樣的查詢?你有一個用戶表試圖從Employee表中填充?你嘗試過哪些SQL? – bowlturner
是的。 EMPLOYEE表。它包括名字 – arun
我已經嘗試了上面的代碼 – arun