Usually we create synonym for table. But can we really create synonym for a schema? Yes, there is an undocumented parameter _enable_schema_synonyms oracle which enables this feature.
Check the parameter status and make it true.
SQL>select ksppinm, ksppstvl from x$ksppi a, x$ksppsv b where a.indx=b.indx and ksppinm like '%schema%synonym%' KSPPINM KSPPSTVL ---------------------------- ------------ _enable_schema_synonyms FALSE --- MAKE the value TRUE SQL> ALTER SYSTEM SET "_enable_schema_synonyms" = true SCOPE=SPFILE; System altered SQL> STARTUP FORCE SQL> show parameter synonym NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ _enable_schema_synonyms boolean TRUE
Now Lets say you have a schema named ORA and you want to create synonym for that schema ORASYN
SQL> select user#,name,type#,ctime from sys.user$ where name like 'ORA%'; USER# NAME TYPE# CTIME ---------- ------------- ---------- --------- 100 ORA 1 21-JUL-15 Note above , the type = 1. SQL> CREATE SCHEMA SYNONYM ORASYN for ORA; Schema synonym created. SQL> select user#,name,type#,ctime,spare2 from sys.user$ where name like 'ORA%'; USER# NAME TYPE# CTIME SPARE2 ---------- ---------- ---------- --------- ---------- 100 ORA 1 21-JUL-15 101 ORASYN 3 21-JUL-15 100
Note that for ORASYN , type =3 which means its a schema synonym and if you see spare value which is 100 means ORASYN is pointing to user# 100 which is user ORA.
Now if you want to create any table using the schema name ,its possible.
For Ex:
CREATE TABLE ORASYN.TAB1(id number(10));
This table will be actually created in ORA schema. Its just using ORASYN as a synonym. This is not renaming a schema name but can be helpful where you mistype the schema name.
This Feature is not officially supported.