Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change schema name?

I have created a user:

CREATE USER gds_map
IDENTIFIED BY gds_map;

And now I need to change a name. I tried to update or find other way but have not found nothing yet.

I will be glad of any hint.

like image 298
adelak Avatar asked Sep 11 '13 00:09

adelak


People also ask

How do you change the schema name in SQL?

To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema. ALTER SCHEMA uses a schema level lock.

How do I change the schema name in SQL Developer?

Just create a new connection (hit the green plus sign) and enter the schema name and password of the new default schema your DBA suggested. You can switch between your old schema and the new schema with the pull down menu at the top right end of your window.


2 Answers

If you want to modify a schema's name,you should have the preveledegs on USER$

1. Get Id of a schema's name

SQL> select user#,NAME from SYS.user$ WHERE NAME='TEST';
USER# NAME
---------- ------------------------------
*93* TEST

2. modify the schema's name

SQL> UPDATE USER$ SET NAME='NEW_SCHEMA_NAME' WHERE USER#=93;

3. finished commit

SQL> COMMIT;

4. modify the system SCN

SQL> ALTER SYSTEM CHECKPOINT;

5.Then refresh shared_pool

SQL> ALTER SYSTEM FLUSH SHARED_POOL;

6. Modify the new schema's password

SQL> ALTER USER new_schema  IDENTIFIED BY new_pass;
like image 100
mohamed stitane Avatar answered Sep 24 '22 06:09

mohamed stitane


I've needed to do this so often that I even wrote an article about this topic

The workaround that I use is to "clone" the user to the same DB with a different name, using loopback dblink.

It's very fast and in the end, after a successful checkup, you can drop the old schema.

Check it here: http://www.dbarj.com.br/en/2014/11/rename-schema-oracle-11g-loopback-dblink/

Regards,

Rodrigo Jorge

like image 32
Rodrigo de Araujo Jorge Avatar answered Sep 20 '22 06:09

Rodrigo de Araujo Jorge