Home » RDBMS Server » Server Utilities » Clone Database user (Oracle 11g 11.2.0.1.0)
Re: Clone Database user [message #518444 is a reply to message #518247] Wed, 03 August 2011 23:52 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Hi All,

Below is the content of the batch file without using network link:

set /P Service_Name=Enter the Service_Name of Database:
sqlplus scott1/tiger@'%Service_Name%' @copy_user_sql.sql
echo   ******Ready to Export the Data of OLD_USER******
echo   ================================================

set /P Old_UserName=Enter Old Username:
set /P New_UserName=Enter New Username:
set /P FileName=Enter Dumpfile Name:
set /P ServiceName=Enter Service Name:

expdp scott1/tiger@'%ServiceName%' file='%FileName%.dmp' directory=DATA_PUMP_DIR logfile='%FileName%_exp.log' schemas=%Old_UserName% exclude=statistics

echo   ******Ready to Import Data into NEW_USER******
echo   ================================================

impdp scott1/tiger@'%ServiceName%' file='%FileName%.dmp' directory=DATA_PUMP_DIR logfile='%FileName%_imp.log' REMAP_SCHEMA= %Old_UserName%:%New_UserName% 
cmd



Below are the parameter that you have to input:

Old Username. [ Username whose copy you want to make.]
New Username. [ New User in which the data will be copied.]
Service Name. [Service name of the database.]
Datapump Directory.[In my case I have taken the default directory][DATA_PUMP_DIR]

You can modify the parameters and the script accordingly as per you requirement.

The script which I have used mentioned in the second line as "@copy_user_sql.sql", have got from the internet which clones a user and grant even all the object level privileges (EXACT CPOY) to the user.

Thanks n Regards
Deepak

[Updated on: Wed, 03 August 2011 23:56]

Report message to a moderator

Re: Clone Database user [message #518448 is a reply to message #518444] Thu, 04 August 2011 00:06 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Hi All,

Below is the content of the batch file using network link:

set /P Service_Name=Enter the Service_Name of Database:
set /P Old_UserName=Enter Old Username:
set /P Old_UserPassword=Enter Old User Password:
set /P Database_link=Enter the Database link name:
sqlplus %Old_UserName%/%Old_UserPassword%@'%Service_Name%' 

create public database link %Database_link% connect to %Old_UserName% identified by %Old_UserPassword% using %Service_Name%;

echo   ******Ready to Export the Data of OLD_USER******
echo   ================================================

set /P Old_UserName=Enter Old Username:
set /P New_UserName=Enter New Username:

echo   ******Ready to Import Data into NEW_USER******
echo   ================================================

impdp %Old_UserName% directory=DATA_PUMP_DIR REMAP_SCHEMA= %Old_UserName%:%New_UserName% NETWORK_LINK=%Database_link% exclude=STATISTICS 
cmd


Below are the parameter that you have to input:

Old Username. [ Username whose copy you want to make.]
New Username. [ New User in which the data will be copied.]
Service Name. [Service name of the database.]
Datapump Directory.[In my case I have taken the default directory][DATA_PUMP_DIR]
Database Link. [Name of the database link which will be used to import in using network mode.]

You can modify the parameters and the script accordingly as per you requirement.

Here I have not used the script used in the privious example, you can also exclude that if you donot want to give the user privileges to deep level
including you dba_proxies privileges etc

Thanks n Regards
Deepak
Re: Clone Database user [message #518449 is a reply to message #518444] Thu, 04 August 2011 00:08 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Interesting post.
I don't understand why you shared this with us.

It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
Re: Clone Database user [message #518451 is a reply to message #518449] Thu, 04 August 2011 00:11 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That would most probably be a feedback, based on the whole yesterday's discussion. Did you read it? The discussion, I mean.
Re: Clone Database user [message #518452 is a reply to message #518448] Thu, 04 August 2011 00:22 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Thanks Everyone

[Updated on: Thu, 04 August 2011 00:24]

Report message to a moderator

Re: Clone Database user [message #518453 is a reply to message #518451] Thu, 04 August 2011 00:24 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Thanks Smile

[Updated on: Thu, 04 August 2011 00:32]

Report message to a moderator

Re: Clone Database user [message #518482 is a reply to message #518453] Thu, 04 August 2011 01:48 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Now I want to create a dump table in which should contain the name of the "New_User" created from this script only with name of "Old_User" from whom it was created and date-time.

So whenever this batch file is run and a user is created, the information should send to this dummy table.

Regards
Deepak

[Updated on: Thu, 04 August 2011 01:51]

Report message to a moderator

Re: Clone Database user [message #518483 is a reply to message #518482] Thu, 04 August 2011 01:50 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Create a table.
Create a SQL script that will insert old and new user names into that table.
Call the SQL script from your batch script - pass Old_UserName and New_UserName as parameters.
Re: Clone Database user [message #518484 is a reply to message #518483] Thu, 04 August 2011 01:52 Go to previous messageGo to next message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

K thanks for the reply, I'' do and update you with the result.

Regards
Deepak
Re: Clone Database user [message #518493 is a reply to message #518483] Thu, 04 August 2011 02:44 Go to previous message
dkdms2124
Messages: 369
Registered: April 2010
Location: INDIA
Senior Member

Done Sir, everything completed successfully.

Thanks
Deepak
Previous Topic: How to skip last n no of records in sql Loader load
Next Topic: Backup
Goto Forum:
  


Current Time: Tue Apr 23 08:02:22 CDT 2024