我使用Oracle XE開發PHP應用程序的唯一目的,而版本11g顯然已經失去了GUI工具來管理用戶,這些用戶使用10g所以我想準備用於從命令行創建用戶的代碼片段。我想define variables所以我並不需要鍵入相同的用戶名16次,但我不能得到正確的語法:從PL/SQL塊中的字符串變量創建用戶
DECLARE
my_user VARCHAR2(30) := 'foo';
my_password VARCHAR2(9) := '1234';
BEGIN
CREATE USER my_user IDENTIFIED BY my_password DEFAULT TABLESPACE users;
GRANT CONNECT, RESOURCE TO my_user;
GRANT CREATE DATABASE LINK TO my_user;
GRANT CREATE MATERIALIZED VIEW TO my_user;
GRANT CREATE PROCEDURE TO my_user;
GRANT CREATE PUBLIC SYNONYM TO my_user;
GRANT CREATE ROLE TO my_user;
GRANT CREATE SEQUENCE TO my_user;
GRANT CREATE SYNONYM TO my_user;
GRANT CREATE TABLE TO my_user;
GRANT CREATE TRIGGER TO my_user;
GRANT CREATE TYPE TO my_user;
GRANT CREATE VIEW TO my_user;
GRANT SELECT_CATALOG_ROLE TO my_user;
GRANT SELECT ANY DICTIONARY TO my_user;
END;
/
CREATE USER my_user IDENTIFIED BY my_password DEFAULT TABLESPACE users; * ERROR en línea 5: ORA-06550: line 5, column 2: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: (begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
難道是禁止使用CREATE USER
聲明來自PL/SQL塊或我只是做了一個愚蠢的錯字?是否必須使用SQL * Plus變量?
響亮而清晰,非常感謝。我想這有助於解釋爲什麼SQL * Plus變量是如此流行的選擇。 –
@ÁlvaroGonzález不客氣!請注意,這些是數據庫管理任務,通常不是通過PL/SQL程序完成的。您只創建一次用戶並授予權限。 DBA需要這樣做,通常不是由PL/SQL開發人員來完成。我不知道你的具體要求,所以你可能有一個用例,雖然;-) –
我確切的要求是,在鎮上沒有DBA,但我仍然需要甲骨文;-) –