Quick Search:
 
 The Oracle PL/SQL PUBLIC Keyword      [Return To Index] Jump to:  

Term: PUBLIC

Definition:
In Oracle PL/SQL, the PUBLIC keyword is used to create public database objects, which are accessible to all users. The database objects which can be created as Public are synonyms and database links. Note that public objects are non schema objects.

GRANT and REVOKE DCL commands use the PUBLIC keyword to grant or remove access rights or privileges on an object to all users.

Example Syntax:

To create a Public Synonym

CREATE PUBLIC SYNONYM [NAME]
FOR [DATABASE OBJECT]


To create a Public Database Link

CREATE PUBLIC DATABASE LINK [NAME]
USING [CONNECT STRING]


To GRANT/REVOKE privilege to/from PUBLIC

GRANT [PRIVILEGE] ON [OBJECT NAME] TO PUBLIC


Example Usage

The SQL statement below creates a database link named DBPROD USING 'DBROD':

CREATE PUBLIC DATABASE LINK DBPROD
USING 'DBPROD';


The SQL statement below creates a Public synonym named ORDERS for the ORDERS table in the SCOTT schema. Note that no private synonym with the name ORDERS should exist in SCOTT schema or else the dependent object would be invalidated.

CREATE PUBLIC SYNONYM ORDERS
FOR SCOTT.ORDERS


The DCL statement below grants SELECT and DML privileges on the ORDERS table to PUBLIC:

GRANT SELECT, INSERT, UPDATE, DELETE
ON ORDERS TO PUBLIC;



Related Links:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org