Skip to content

Latest commit

 

History

History
104 lines (76 loc) · 3.23 KB

SAVE_AUTH.rst

File metadata and controls

104 lines (76 loc) · 3.23 KB

SAVE_AUTH procedure

Saves the authorizations of the specified relation for later restoration with RESTORE_AUTH.

Prototypes

SAVE_AUTH(ASCHEMA VARCHAR(128), ATABLE VARCHAR(128))
SAVE_AUTH(ATABLE VARCHAR(128))

Description

SAVE_AUTH is a utility procedure which copies the authorization settings for the specified table or view from SYSCAT.TABAUTH to SAVED_AUTH (a utility table which exists in the same schema as the procedure). These saved settings can then be restored with the RESTORE_AUTH procedure. These procedures are primarily intended for use in conjunction with the other schema evolution functions (like RECREATE_VIEWS).

Warning

Column specific authorizations (stored in SYSCAT.COLAUTH) are not saved and restored by these procedures.

Note

SAVE_AUTH and RESTORE_AUTH are not used directly by RECREATE_VIEW because when a view is marked inoperative, all authorization information is immediately wiped from SYSCAT.TABAUTH. Hence, there is nothing to restore by the time RECREATE_VIEW is run.

You must call SAVE_AUTH before performing the operation that will invalidate the view, and RESTORE_AUTH after running RECREATE_VIEW. Alternatively, you may wish to use SAVE_VIEW and RESTORE_VIEW instead, which rely on SAVE_AUTH and RESTORE_AUTH implicitly.

Parameters

ASCHEMA

The name of the schema containing the table for which authorizations are to be saved. If this parameter is omitted, it defaults to the value of the CURRENT SCHEMA special register.

ATABLE

The name of the table within ASCHEMA for which authorizations are to be saved.

Examples

Save the authorizations associated with the FINANCE.LEDGER table, drop the table, recreate it with a definition derived from another table, then restore the authorizations:

SET SCHEMA FINANCE;
CALL SAVE_AUTH('LEDGER');
DROP TABLE LEDGER;
CREATE TABLE LEDGER LIKE LEDGER_TEMPLATE;
CALL RESTORE_AUTH('LEDGER');

Advanced usage: Copy the authorizations associated with FINANCE.SALES to FINANCE.SALES_HISTORY by changing the content of the SAVED_AUTH table (which is structured identically to the SYSCAT.TABAUTH table) between calls to SAVE_AUTH and RESTORE_AUTH:

SET SCHEMA FINANCE;
CALL SAVE_AUTH('SALES');
UPDATE UTILS.SAVED_AUTH
    SET TABNAME = 'SALES_HISTORY'
    WHERE TABNAME = 'SALES'
    AND TABSCHEMA = CURRENT SCHEMA;
CALL RESTORE_AUTH('SALES_HISTORY');

See Also