Public Synonym in Database


Creating the public synonym allows the user to reference the table name without prefixing the record name with the schema owner (SYSADM.PS_PERSON) or performing an ALTER SESSION command.

Note: Use public synonyms when the database only has one schema owner for all tables. example PeopleSoft Application


Create Public Synonym for an Object

Note: the Public Synonym should be the same name as the record

CREATE PUBLIC SYNONYM PS_PERSON FOR PS_PERSON;

To find which tables do not have a public synonym and create script automatically

SELECT 'CREATE PUBLIC SYNONYM ' || OBJECT_NAME || ' FOR ' || OBJECT_NAME || ';'
FROM DBA_OBJECTS A
WHERE A.OBJECT_TYPE IN ('TABLE', 'VIEW')
  AND A.OBJECT_NAME LIKE 'PS_ %'
  AND A.TIMESTAMP > '01-AUG-2012'
  AND NOT EXISTS (SELECT '1' FROM DBA_SYNONYMS B
                  WHERE B.OWNER = 'PUBLIC' AND
                  B.SYNONYM_NAME = A.OBJECT_NAME)
ORDER BY TIMESTAMP DESC


PeopleSoft DBA or ADMIN Reference:

For the Oracle installation, the only public synonym that PeopleSoft delivers to you is in script DBOWNER.SQL: 

set echo on
spool dbowner.log

GRANT CONNECT, RESOURCE, DBA TO PS IDENTIFIED BY PS;
CONNECT PS/PS;
CREATE TABLE PSDBOWNER (DBNAME VARCHAR2(8) NOT NULL, OWNERID VARCHAR2(8) NOT NULL ) TABLESPACE PSDEFAULT;
CREATE UNIQUE INDEX PS_PSDBOWNER ON PSDBOWNER (DBNAME) TABLESPACE PSDEFAULT;
CREATE PUBLIC SYNONYM PSDBOWNER FOR PSDBOWNER;
GRANT SELECT ON PSDBOWNER TO PUBLIC;
CONNECT SYSTEM/MANAGER;
REVOKE CONNECT, RESOURCE, DBA FROM PS;


Note: Any other public synonyms; present in your environment, were created by PeopleSoft DBA or Admin and maintained by him / her.