• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Oracle - user creation script

blanck

n00b
Joined
Dec 9, 2007
Messages
23
I often need to create a handful of Oracle user schemas for test builds. I generally use the following two commands in sqlplus:

Code:
CREATE USER username IDENTIFIED BY password DEFAULT TABLESPACE users;
GRANT connect, resource TO username;

This works fine, but I would really like to make my life easier and combine the 6 or so user creation statements into a .sql file and just run the script in sqlplus. I naively constructed a script in the following way:

Code:
begin
CREATE USER ...
GRANT ...
CREATE USER ...
GRANT ...
...
end;
/

sqlplus complains aboout the first 'CREATE USER' statement, saying that it is an invalid way to begin a command. Indeed, 'CREATE' is not one of the acceptable statements it lists in the error message. I tried Googling around, but could not find quite what I'm looking for.

What is the correct syntax for creating users and granting permissions in an equivalent way to my two sqlplus commands in an Oracle .sql script? I am using Oracle 10.2 Express Edition.

Thanks in advance!
 
Figured out a solution, in case anyone else runs into this problem: There was no need to surround the code with a 'begin' and 'end.'

Just having the statements in a file delimited by semi-colons was enough to get it to work.
 
Back
Top