Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Namespacing within a schema ("sub-schema")

Jeffrey KempFeb 20 2019 — edited Feb 20 2019

Currently, when loading a 3rd party PL/SQL library, to avoid collisions with object names that already existing in your system you need to create a dedicated schema (user) for that library. e.g. creating the "LOGGER" schema to install Logger.

In hosted environments, you often only get one schema (or extra schemas are extra cost) so you do your best to load the 3rd party library into your single schema and resolve any conflicts manually.

In addition, the sheer number of objects in a single schema can get quite large (e.g. in a typical e-Business Suite Financials application the APPS_FND schema can accumulate a large quantity of objects); it would be useful to be able to group objects (tables, views, packages, synonyms, etc.) and have the ability to refer to an object within any particular group; in addition, it would be useful to be able to have an object with the same name appear in more than one group.

Credit goes to @"Dietmar Aust" for the idea (https://twitter.com/daust_de/status/1074225472832241664 ).

One idea for the syntax that could support this feature with would be to add the concept of a "subschema". A subschema is a namespace owned by a particular schema (user). It can have its own quota, but its objects are also constrained by the owner's quota as well. This syntax would necessitate some augmentation to the identifier parsing rules in SQL and PL/SQL.

create user LOGGER under SCOTT; -- new syntax "under". Note: no "identified by", no "account lock", and no profile would be applicable.

alter session set current_schema = SCOTT.LOGGER;

create or replace package logger as ...; -- this object would be owned by SCOTT and exist in the SCOTT.LOGGER namespace

exec logger.log('Hello world'); -- this works

alter session set current_schema = SCOTT;

exec logger.log('Hello world'); -- this fails because SCOTT doesn't have an object "logger"

exec LOGGER.logger.log('Hello world'); -- this works because SCOTT can refer to any object in its subschemas

create synonym LOGGER for LOGGER.logger; -- we can create local synonyms for objects in a subschema

exec logger.log('Hello world'); -- this works now because of the synonym

grant execute on SCOTT.LOGGER.logger to HR; -- grant to other users

grant execute on SCOTT.LOGGER.logger to SCOTT.OTHERMODULE; -- grant to other subschemas

conn HR;

create synonym HR.LOGGER for SCOTT.LOGGER.logger; -- create synonyms for objects in another user's subschema

exec logger.log('Hello world');

Comments
Post Details
Added on Feb 20 2019
8 comments
1,542 views