Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

help needed for user creation in database

Adrian_72
Advisor

help needed for user creation in database

I need create 1500 users in Oracle database on UNIX
I have two files the first is the usernames and the second is the passwords. my users have a diferent password

any idea about generate the script

Thanks for all the responses
5 REPLIES

Re: help needed for user creation in database

You could use a program and read a record out of one, read a record out of the other, and create the script to create the user.

What I'd do is create a table with a number key, username and password fields. I'd load the username with a counter into the table. Then I'd update the records with the password using a counter. Then it would be a simple script like in your last post

spool creator.sql
select 'create user '||username_v||' identified by '||password_field||' default tablespace siebeldata temporary tablespace temp;',
'grant role_1, connect to '|| name
from my_name_table;
spool off
@@creator.sql

Hein van den Heuvel
Honored Contributor

Re: help needed for user creation in database


Hmmm, scary thought to have two seperate lists for that. They could not generate them into one list?

Anyway... this problem is much similar to:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=650699

One potential solution in awk:

awk '{getline pass < "passwords.dat"; print "create user",$1,"identified by",pass,"default blah blah..."}' usernames.dat

So here the main awk loop reads "usernames" and feeds them into $0, $1 and so on.
THen for every record read, we start py reading a line from "passwords" into symbol pass and print that along with the sql text and $1 (the first and only field from "usernames".

Good luck.

Hein.

Adrian_72
Advisor

Re: help needed for user creation in database

Hein Van Den;

Thank you

I execute the next:
awk '{getline pass < "passwords.dat"; print "create user",$1,"identified by",pas
s,"default tablespace siebeldata temporary tablespace temp; grant sse_role,creat
e session to",$1,";"}' usernames.dat > /tmp/users/yo.sql

but I can't execute the yo.sql file

The yo.sql file is:

create user CAP101 identified by DEMO1 default tablespace siebeldata temporary tablespace temp; grant sse_role,create session to CAP101 ;

I need insert a line before the grant
how I can put this line?

Yogeeraj_1
Honored Contributor

Re: help needed for user creation in database

hello,

it seems like you have two posts for the same questions.

please refer to the other post.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=654889

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Petr Simik_1
Valued Contributor

Re: help needed for user creation in database

not real hpux admin way but easy is to use MS excel and concatenate function this is very quick and easy for making scripts like this it is interactive.