Home » Infrastructure » Unix » script to log into all oracle databases in one unix server
script to log into all oracle databases in one unix server [message #98481] Sun, 21 November 2004 09:08 Go to next message
Madhu
Messages: 36
Registered: April 2001
Member
Hi,

i want to create  a shell script to log into all the oracle databases hosted on one unix server, and create users on each oracle database . 

thanks

madhu
Re: script to log into all oracle databases in one unix server [message #98482 is a reply to message #98481] Mon, 22 November 2004 05:00 Go to previous messageGo to next message
Jai Vrat Singh
Messages: 205
Registered: September 2002
Location: Singapore
Senior Member
See use of UNIX "here" document

e.g.
#!/bin/ksh

sqlplus madhu@databasename/gossip123<<<b>STR</b>

create user kukku
identified by kukku123
default tablespace USERS
temporary tablespace TEMP
quota unlimited on USERS
quota 10M on TEMP
quota 0M on SYSTEM;

grant create session, resource
to kukku;

STR


if you have lots of users to be created on many databases, then put the users and their passwords ina file and give the aboe command in a loop which will repeat around the contents of the file containig databases and usernames and passwords. For simplicity you can take default passwords of users as <username>123 .
I think you want this only?

#!/bin/ksh

for dbname in `cat dblist.txt`
do
  for user in `cat userlist.txt`
  do
    sqlplus admin@$dbname/adminpasswd<<<b>STR</b>

       create user $user
       identified by $user123
       default tablespace USERS
       temporary tablespace TEMP
       quota unlimited on USERS
       quota 10M on TEMP
       quota 0M on SYSTEM;
    STR
  done
done



I have not tested it. But it will be like this.
Re: script to log into all oracle databases in one unix server [message #98483 is a reply to message #98482] Mon, 22 November 2004 06:48 Go to previous message
Madhu
Messages: 36
Registered: April 2001
Member
hi,
i have 10 databases with different sid's on 1 server. i just want to create 5 users on each database of the server.creating user is not a issue. i want the different sid's to be initialised in the loop..
Previous Topic: Date format in Korn Shell script
Next Topic: multiple databases & charcterset
Goto Forum:
  


Current Time: Tue Apr 23 22:13:28 CDT 2024