*   *ID* ORADDV   CMD      changed on 1994-12-15-12.36.43 by KRISCHAN  *

* This command file contains descriptions of the data dictionary tables
* and views. To see the current data dictionary on your system,
* query the view DICTIONARY.
*


SQLMODE ADABAS
*
INIT SERVERDB
*
USE USER sys sys
*

*
* ==================================
* Part 1) User Data Dictionary Views
* ==================================
*
* The following is an alphabetical reference of the data dictionary views
* accessible to all users of the database. Most views can be accessed by
* any user with the CREATE_SESSION privilege
*

CREATE VIEW all_catalog
       (owner, table_name, table_type)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        EXPAND (type,      11)
      FROM sysdd.tables
  UNION ALL
    SELECT
        EXPAND (owner,         30),
        EXPAND (sequence_name, 30),
        'SEQUENCE   '
      FROM sysdd.sequences
*
GRANT ALL ON all_catalog TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_col_comments
       (owner, table_name, column_name, comments)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        EXPAND (columnname, 30),
        comment_c
    FROM sysdd.columns
*
GRANT ALL ON all_col_comments TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_col_privs
      (grantor, grantee, table_schema, table_name, column_name,
       privilege, grantable)
  AS SELECT
        EXPAND (grantor, 30),
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (name2,   30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NOT NULL AND grantor <> grantee
*
GRANT ALL ON all_col_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_col_privs_made
      (grantee, owner, table_name, column_name, grantor, privilege, grantable)
  AS SELECT
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (name2,   30),
        EXPAND (grantor, 30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NOT NULL AND grantor <> grantee
       AND (grantor = USERGROUP OR owner = USERGROUP)
*
GRANT ALL ON all_col_privs_made TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_col_privs_recd
      (grantee, owner, table_name, column_name, grantor, privilege, grantable)
  AS SELECT
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (name2,   30),
        EXPAND (grantor, 30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NOT NULL AND grantor <> USERGROUP
       AND (grantee = USERGROUP OR grantee = 'PUBLIC')
*
GRANT ALL ON all_col_privs_recd TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_constraints
      (owner, constraint_name, constraint_type, table_name,
       search_condition, r_owner, r_constraint_name, delete_rule, status)
    AS SELECT
        EXPAND (owner,          30),
        EXPAND (constraintname, 30),
        'C ',
        EXPAND (tablename,      30),
        definition_c,
        EXPAND (NULL, 30),
        EXPAND (NULL, 30),
        EXPAND (NULL, 10),
	'ENABLED '
    FROM sysdd.constraints
UNION ALL SELECT
       EXPAND (owner,     30),
       'C' || tablename || CHR (columnno),
       'C ',
       EXPAND (tablename, 30),
       columnname || ' IS NOT NULL',
       EXPAND (NULL, 30),
       EXPAND (NULL, 30),
       EXPAND (NULL, 10),
       'ENABLED '
   FROM sysdd.columns
   WHERE mod = 'MAN'
UNION ALL SELECT
       EXPAND (owner,      30),
       'P' || tablename || CHR (keycolumnno),
       'P ',
       EXPAND (tablename,  30),
       EXPAND (columnname, 30),
       EXPAND (NULL, 30),
       EXPAND (NULL, 30),
       EXPAND (NULL, 10),
       'ENABLED '
  FROM sysdd.columns
  WHERE keycolumnno IS NOT NULL
UNION ALL SELECT
       EXPAND (owner,      30),
       EXPAND (refname,    30),
       'R ',
       EXPAND (tablename,  30),
       EXPAND (columnname, 30),
       EXPAND (refowner,   30),
       EXPAND (NULL, 30),
       DECODE (rule, 'DELETE CASCADE',  'CASCADE',
                     'DELETE RESTRICT', 'NO ACTION',
                                        rule),
       'ENABLED '
  FROM sysdd.foreign_keys
*
GRANT ALL ON all_constraints TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_cons_columns
      (owner, constraint_name, table_name, column_name, position)
    AS SELECT
        EXPAND (owner,          30),
	DECODE (type, 'KEY', 'P' || columnname || CHR (columnno),
                             EXPAND (constraintname, 30)),
        EXPAND (tablename,      30),
        EXPAND (columnname,     30),
        DECODE (type, 'CHECK', NULL, columnno)
       FROM sysdd.constraintcolumns
*
GRANT ALL ON all_cons_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_db_links
      (owner, db_link, username, host, created)
    AS SELECT
        EXPAND (' ',  30),
        EXPAND (' ',  30),
        EXPAND (' ',  30),
        EXPAND (' ', 254),
        TIMESTAMP (DATE, TIME)
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON all_db_links TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_def_audit_opts
      (alt, aud, com, del, gra, ind, ins, loc, ren, sel, upd, ref, exe)
    AS SELECT
       '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-',
       '-/-', '-/-', '-/-', '-/-', '-/-'
      FROM dual
*
GRANT ALL ON all_def_audit_opts TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_dependencies
       (owner, name, type, referenced_owner, referenced_name, referenced_type,
        referenced_link_name)
  AS SELECT
       EXPAND (owner,        30),
       EXPAND (tablename,    30),
       'VIEW        ',
       EXPAND (refname,      30),
       EXPAND (reftablename, 30),
       'TABLE       ',
       EXPAND (NULL, 30)
     FROM sysdd.view_uses_table
*
GRANT ALL ON all_dependencies TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_errors
       (owner, name, type, sequence, line, position, text)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  12),
       999, 1, 1,
       EXPAND (' ',  200)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON all_errors TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_indexes
      (owner, index_name, table_owner, table_name, table_type, uniqueness,
       tablespace_name, ini_trans, max_trans, initial_extent, next_extent,
       min_extents, max_extents, pct_increase, pct_free, blevel, leaf_blocks,
       distinct_keys, avg_leaf_blocks_per_key, avg_data_blocks_per_key,
       clustering_factor, status)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (indexname,  30),
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        'TABLE      ',
        DECODE (type, ' ', 'NONUNIQUE', type),
	'SYSTEM                        ',
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
	distinctvalues,
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
	'VALID      '
    FROM sysdd.indexes
       WHERE indexname <> ' ' AND columnno = 1
*
GRANT ALL ON all_indexes TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_ind_columns
      (index_owner, index_name, table_owner, table_name,
       column_name, column_position, column_length)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (indexname,  30),
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        EXPAND (columnname, 30),
        columnno,
        DECODE (datatype, 'NUMBER',    22,
                          'FLOAT',     22,
                          'DATE',      7,
                          'LONG',      28,
                                       len)
    FROM sysdd.indexes
      WHERE indexname <> ' '
*
GRANT ALL ON all_ind_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_objects
      (owner, object_name, object_id, object_type, created,
       last_ddl_time, "TIMESTAMP", status)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        tableid,
        EXPAND (type,       11),
        TIMESTAMP ("DATE", "TIME"),
        TIMESTAMP (VALUE (TIMESTAMP (alterdate, altertime),
                          TIMESTAMP ("DATE",    "TIME"))),
        EXPAND (CHAR ("DATE", JIS) || ':' || CHAR ("TIME", JIS), 75),
	'VALID  '
    FROM sysdd.tables
  UNION ALL
    SELECT
        EXPAND (owner,         30),
        EXPAND (sequence_name, 30),
        NO,
        'SEQUENCE',
        TIMESTAMP ("DATE", "TIME"),
        TIMESTAMP ("DATE", "TIME"),
        EXPAND (CHAR ("DATE", JIS) || ':' || CHAR ("TIME", JIS), 75),
	'VALID  '
      FROM sysdd.sequences
  UNION ALL
    SELECT
        EXPAND (owner,     30),
        EXPAND (indexname, 30),
        NULL,
        'INDEX',
        TIMESTAMP ("DATE", "TIME"),
        TIMESTAMP ("DATE", "TIME"),
        EXPAND (CHAR ("DATE", JIS) || ':' || CHAR ("TIME", JIS), 75),
	'VALID  '
      FROM sysdd.indexes
      WHERE columnno = 1
*
GRANT ALL ON all_objects TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_sequences
      (sequence_owner, sequence_name, min_value, max_value, increment_by,
       cycle_flag, order_flag, cache_size, last_number)
    AS SELECT
        EXPAND (owner,         30),
        EXPAND (sequence_name, 30),
        min_value,
        max_value,
        increment_by,
        cycle_flag,
        order_flag,
        cache_size,
        last_number
    FROM sysdd.sequences
*
GRANT ALL ON all_sequences TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_snapshots
       (owner, name, table_name,
        master_view, master_owner, master, master_link,
        can_use_log, last_refresh, error, type, "NEXT", start_with, query)
  AS SELECT
       EXPAND (owner,            30),
       EXPAND (tablename,        30),
       EXPAND (NULL,             30),
       EXPAND (master_owner,     30),
       EXPAND (master_tablename, 30),
       EXPAND (NULL,             30),
       EXPAND (NULL,             30),
       fast_refreshable,
       TIMESTAMP (NULL, NULL),
       FIXED (NULL),
       'FORCE   ',
       EXPAND (NULL, 254),
       TIMESTAMP (NULL, NULL),
       definition
     FROM sysdd.snapshots
*
GRANT ALL ON all_snapshots TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_source
      (owner, name, type, line, text)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  11),
       1,
       EXPAND (' ',  200)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON all_source TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_synonyms
      (owner, synonym_name, table_owner, table_name, db_link)
    AS SELECT
        EXPAND (synonymowner, 30),
        EXPAND (synonymname,  30),
        EXPAND (owner,        30),
        EXPAND (tablename,    30),
        EXPAND (NULL,         30)
      FROM sysdd.db_synonyms
      WHERE synonymowner = USERGROUP OR synonymowner = 'PUBLIC'
*
GRANT ALL ON all_synonyms TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_tables
      (owner, table_name, tablespace_name, cluster_name,
       pct_free, pct_used, ini_trans, max_trans,
       initial_extent, next_extent, min_extents, max_extents, pct_increase,
       backed_up, num_rows, blocks, empty_blocks, avg_space, chain_cnt,
       avg_row_len)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        'SYSTEM                        ',
        EXPAND (NULL, 30),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        'N',
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL),
        FIXED (NULL)
      FROM sysdd.tables
        WHERE type = 'TABLE'
*
GRANT ALL ON all_tables TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_tab_columns
            (owner, table_name, column_name,
            data_type, data_length, data_precision, data_scale,
            nullable, column_id, default_length, data_default,
	    num_distinct, low_value, high_value, density)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        EXPAND (columnname, 30),
        DECODE (datatype, 'CHAR',    DECODE (code, 'BYTE', 'RAW', 'VARCHAR2'),
                          'FLOAT',   DECODE (len, NULL, 'NUMBER', 'FLOAT'),
                          'VARCHAR', 'VARCHAR2',
                                     SUBSTR (datatype, 1, 9)),
        DECODE (datatype, 'NUMBER', 22,
                          'FLOAT',  22,
                          'DATE',    7,
                          'LONG',   28,
                                       len),
        DECODE (datatype, 'NUMBER', len, 'FLOAT', len),
        DECODE (datatype, 'NUMBER', dec),
        DECODE (mod || DECODE ("DEFAULT", NULL, '-NOD'), 'OPT-NOD', 'Y', 'N'),
        columnno,
        DECODE (datatype, 'NUMBER', LENGTH (LTRIM ("DEFAULT")),
                          'FLOAT',  LENGTH (LTRIM ("DEFAULT")),
                                    LENGTH ("DEFAULT"))
        +
        DECODE (mod, 'OPT', 0, 1),
        "DEFAULT",
        distinctvalues,
        NULL,
        NULL,
        FIXED (NULL)
      FROM sysdd.columns
*
GRANT ALL ON all_tab_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_tab_comments
      (owner, table_name, table_type, comments)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        EXPAND (type,      11),
        comment_c
    FROM sysdd.tables
      WHERE type = 'TABLE' OR  type = 'VIEW'
*
GRANT ALL ON all_tab_comments TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_tab_privs
      (grantor, grantee, table_schema, table_name, privilege, grantable)
  AS SELECT
        EXPAND (grantor, 30),
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NULL AND grantor <> grantee
*
GRANT ALL ON all_tab_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_tab_privs_made
      (grantee, owner, table_name, grantor, privilege, grantable)
  AS SELECT
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (grantor, 30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NULL AND grantor <> grantee
       AND (grantor = USERGROUP OR owner = USERGROUP)
*
GRANT ALL ON all_tab_privs_made TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_tab_privs_recd
      (grantee, owner, table_name, grantor, privilege, grantable)
  AS SELECT
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (grantor, 30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NULL AND grantor <> grantee
       AND (grantee = USERGROUP OR grantee = 'PUBLIC')
*
GRANT ALL ON all_tab_privs_recd TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_triggers
      (owner, trigger_name, trigger_type, triggering_event,
       table_owner, table_name, referencing_names, when_clause,
       status, description, trigger_body)
  AS SELECT
       EXPAND (owner,       30),
       EXPAND (triggername, 30),
       'AFTER EACH ROW  ',
       DECODE (SUBSTR (insert, 1, 1) ||
               SUBSTR (update, 1, 1) ||
               SUBSTR (delete, 1, 1),
               'YNN', 'INSERT',
	       'NYN', 'UPDATE',
	       'NNY', 'DELETE',
	       'YYN', 'INSERT OR UPDATE',
	       'YNY', 'INSERT OR DELETE',
	       'NYY', 'UPDATE OR DELETE',
	       'YYY', 'INSERT OR UPDATE OR DELETE',
                      'ERROR'),
       EXPAND (owner,     30),
       EXPAND (tablename, 30),
       EXPAND (NULL,      87),
       EXPAND (NULL,      200),
       'ENABLED ',
       definition_c,
       NULL
     FROM sysdd.triggers
*
GRANT ALL ON all_triggers TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_trigger_cols
      (trigger_owner, trigger_name,
       table_owner, table_name, column_name, column_list, column_usage)
  AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       'NO ',
       EXPAND (' ', 17)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON all_trigger_cols TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_users
      (username, user_id, created)
    AS SELECT
        EXPAND (username, 30),
        user_id,
        TIMESTAMP ("DATE", "TIME")
    FROM sysdd.users
*
GRANT ALL ON all_users TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW all_views
      (owner, view_name, text_length, text)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        len,
        definition
    FROM sysdd.views
*
GRANT ALL ON all_views TO PUBLIC WITH GRANT OPTION
*

CREATE TABLE audit_actions
      (action FLOAT (18) NOT NULL,
       name   CHAR  (27) NOT NULL
      )
*
GRANT SELECT ON audit_actions TO PUBLIC WITH GRANT OPTION
*
INSERT INTO audit_actions VALUES (0,  'UNKNOWN')
*
INSERT INTO audit_actions VALUES (1,  'CREATE TABLE')
*
INSERT INTO audit_actions VALUES (2,  'INSERT')
*
INSERT INTO audit_actions VALUES (3,  'SELECT')
*
INSERT INTO audit_actions VALUES (4,  'CREATE CLUSTER')
*
INSERT INTO audit_actions VALUES (5,  'ALTER CLUSTER')
*
INSERT INTO audit_actions VALUES (6,  'UPDATE')
*
INSERT INTO audit_actions VALUES (7,  'DELETE')
*
INSERT INTO audit_actions VALUES (8,  'DROP CLUSTER')
*
INSERT INTO audit_actions VALUES (9,  'CREATE INDEX')
*
INSERT INTO audit_actions VALUES (10, 'DROP INDEX')
*
INSERT INTO audit_actions VALUES (11, 'ALTER INDEX')
*
INSERT INTO audit_actions VALUES (12, 'DROP TABLE')
*
INSERT INTO audit_actions VALUES (13, 'CREATE SEQUENCE')
*
INSERT INTO audit_actions VALUES (14, 'ALTER SEQUENCE')
*
INSERT INTO audit_actions VALUES (15, 'ALTER TABLE')
*
INSERT INTO audit_actions VALUES (16, 'DROP SEQUENCE')
*
INSERT INTO audit_actions VALUES (17, 'GRANT OBJECT')
*
INSERT INTO audit_actions VALUES (18, 'REVOKE OBJECT')
*
INSERT INTO audit_actions VALUES (19, 'CREATE SYNONYM')
*
INSERT INTO audit_actions VALUES (20, 'DROP SYNONYM')
*
INSERT INTO audit_actions VALUES (21, 'CREATE VIEW')
*
INSERT INTO audit_actions VALUES (22, 'DROP VIEW')
*
INSERT INTO audit_actions VALUES (23, 'VALIDATE INDEX')
*
INSERT INTO audit_actions VALUES (26, 'LOCK')
*
INSERT INTO audit_actions VALUES (27, 'UNDEFINED')
*
INSERT INTO audit_actions VALUES (28, 'RENAME')
*
INSERT INTO audit_actions VALUES (29, 'COMMENT')
*
INSERT INTO audit_actions VALUES (30, 'AUDIT OBJECT')
*
INSERT INTO audit_actions VALUES (31, 'NOAUDIT OBJECT')
*
INSERT INTO audit_actions VALUES (32, 'CREATE DATABASE LINK')
*
INSERT INTO audit_actions VALUES (33, 'DROP DATABASE LINK')
*
INSERT INTO audit_actions VALUES (34, 'CREATE DATABASE')
*
INSERT INTO audit_actions VALUES (35, 'ALTER DATABASE')
*
INSERT INTO audit_actions VALUES (36, 'CREATE ROLLBACK SEG')
*
INSERT INTO audit_actions VALUES (37, 'ALTER ROLLBACK SEG')
*
INSERT INTO audit_actions VALUES (38, 'DROP ROLLBACK SEG')
*
INSERT INTO audit_actions VALUES (39, 'CREATE TABLESPACE')
*
INSERT INTO audit_actions VALUES (40, 'ALTER TABLESPACE')
*
INSERT INTO audit_actions VALUES (41, 'DROP TABLESPACE')
*
INSERT INTO audit_actions VALUES (42, 'ALTER SESSION')
*
INSERT INTO audit_actions VALUES (43, 'ALTER USER')
*
INSERT INTO audit_actions VALUES (49, 'ALTER SYSTEM')
*
INSERT INTO audit_actions VALUES (60, 'LOGON')
*
INSERT INTO audit_actions VALUES (61, 'LOGOFF')
*
INSERT INTO audit_actions VALUES (62, 'CLEANUP')
*
INSERT INTO audit_actions VALUES (63, 'SESSION')
*
INSERT INTO audit_actions VALUES (64, 'AUDIT SYSTEM')
*
INSERT INTO audit_actions VALUES (65, 'NOAUDIT SYSTEM')
*
INSERT INTO audit_actions VALUES (66, 'AUDIT DEFAULT')
*
INSERT INTO audit_actions VALUES (67, 'NOAUDIT DEFAULT')
*
INSERT INTO audit_actions VALUES (68, 'GRANT SYSTEM')
*
INSERT INTO audit_actions VALUES (69, 'REVOKE SYSTEM')
*
INSERT INTO audit_actions VALUES (70, 'CREATE PUBLIC SYNONYM')
*
INSERT INTO audit_actions VALUES (71, 'DROP PUBLIC SYNONYM')
*
INSERT INTO audit_actions VALUES (72, 'CREATE PUBLIC DATABASE LINK')
*
INSERT INTO audit_actions VALUES (73, 'DROP PUBLIC DATABASE LINK')
*
INSERT INTO audit_actions VALUES (80, 'USER COMMENT')
*

CREATE VIEW column_privileges
      (grantee, owner, table_name, column_name, grantor, insert_priv,
       update_priv, references_priv, created)
    AS SELECT
        EXPAND (grantee, 30),
        EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (name2,   30),
        EXPAND (grantor, 30),
        DECODE (INDEX (privileges, 'INS'), 0, 'N',
                   DECODE (INDEX (privileges, 'INS+'), 0, 'Y', 'G')),
        DECODE (INDEX (privileges, 'UPD'), 0, 'N',
                   DECODE (INDEX (privileges, 'UPD+'), 0, 'Y', 'G')),
        DECODE (INDEX (privileges, 'REF'), 0, 'N',
                   DECODE (INDEX (privileges, 'REF+'), 0, 'Y', 'G')),
        TIMESTAMP ("DATE", "TIME")
    FROM sysdd.privileges
      WHERE name2 IS NOT NULL AND grantor <> grantee
*
GRANT ALL ON column_privileges TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW dictionary (table_name, comments)
AS SELECT
     EXPAND (tablename, 30),
     comment_c
  FROM sysdd.tables
  WHERE owner = 'SYS'
    AND (   tablename LIKE 'USER%'
         OR tablename LIKE 'ALL%'
         OR tablename LIKE 'DBA%'
         OR tablename IN ('AUDIT_ACTIONS', 'COLUMN_PRIVILEGES', 'DICTIONARY',
                          'DICT_COLUMNS', 'DUAL', 'GLOBAL_NAME',
                          'INDEX_HISTOGRAM', 'INDEX_STATS', 'RESOURCE_COST',
                          'ROLE_ROLE_PRIVS', 'ROLE_SYS_PRIVS',
                          'ROLE_TAB_PRIVS', 'SESSION_PRIVS', 'SESSION_ROLES',
                          'TABLE_PRIVILEGES'))
*
GRANT ALL ON dictionary TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW dict_columns (table_name, column_name, comments)
AS SELECT
     EXPAND (tablename,  30),
     EXPAND (columnname, 30),
     comment_c
  FROM sysdd.columns
  WHERE owner = 'SYS'
    AND (   tablename LIKE 'USER%'
         OR tablename LIKE 'ALL%'
         OR tablename LIKE 'DBA%'
         OR tablename IN ('AUDIT_ACTIONS', 'DICTIONARY', 'DICT_COLUMNS',
                           'DUAL'))
*
GRANT ALL ON dict_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW exceptions
      (row_id, owner, table_name, "CONSTRAINT")
  AS SELECT
       1,
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  30)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON exceptions TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW global_name
      (global_name)
  AS SELECT s.serverdb || '.' || s.servernode
       FROM sysdd.users u, sysdd.serverdbs s
       WHERE u.username = SYSDBA AND u.serverdb = s.serverdb
*
GRANT ALL ON global_name TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW public_dependency
      (object_id, referenced_object_id)
  AS SELECT
       o.tableid,
       d.tableid
     FROM sysdd.tables o, sysdd.tables d, sysdd.view_uses_table v
     WHERE v.owner   = o.owner AND v.tablename    = o.tablename
       AND v.refname = d.owner AND v.reftablename = d.tablename
*
GRANT ALL ON public_dependency TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW resource_cost
      (resource_name, unit_cost)
  AS SELECT
       EXPAND (' ', 32),
       0
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON resource_cost TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW role_role_privs
      (role, granted_role, admin_option)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (USER, 30),
       'NO '
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON role_role_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW role_sys_privs
      (role, privilege, admin_option)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  40),
       'NO '
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON role_sys_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW role_tab_privs
      (role, owner, table_name, column_name, privilege, grantable)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  30),
       EXPAND (' ',  30),
       'NO '
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON role_tab_privs TO PUBLIC WITH GRANT OPTION
*

CREATE TABLE role_privs (
  usermode  CHAR(11),
  privilege CHAR(40)
)
*

INSERT INTO role_privs VALUES ('STANDARD', 'CREATE SESSION')
*
INSERT INTO role_privs VALUES ('STANDARD', 'ALTER SESSION')
*
INSERT INTO role_privs VALUES ('STANDARD', 'CREATE TABLE')
*
INSERT INTO role_privs VALUES ('STANDARD', 'CREATE CLUSTER')
*
INSERT INTO role_privs VALUES ('STANDARD', 'CREATE SYNONYM')
*
INSERT INTO role_privs VALUES ('STANDARD', 'CREATE VIEW')
*
INSERT INTO role_privs VALUES ('STANDARD', 'CREATE SEQUENCE')
*
INSERT INTO role_privs VALUES ('STANDARD', 'CREATE DATABASE LINK')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE SESSION')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'ALTER SESSION')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'UNLIMITED TABLESPACE')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE TABLE')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE CLUSTER')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE SYNONYM')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE VIEW')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE SEQUENCE')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE DATABASE LINK')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE PROCEDURE')
*
INSERT INTO role_privs VALUES ('RESOURCE', 'CREATE TRIGGER')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER SYSTEM')
*
INSERT INTO role_privs VALUES ('DBA',      'AUDIT SYSTEM')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE SESSION')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER SESSION')
*
INSERT INTO role_privs VALUES ('DBA',      'RESTRICTED SESSION')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE TABLESPACE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER TABLESPACE')
*
INSERT INTO role_privs VALUES ('DBA',      'MANAGE TABLESPACE')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP TABLESPACE')
*
INSERT INTO role_privs VALUES ('DBA',      'UNLIMITED TABLESPACE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE USER')
*
INSERT INTO role_privs VALUES ('DBA',      'BECOME USER')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER USER')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP USER')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ROLLBACK SEGMENT')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ROLLBACK SEGMENT')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ROLLBACK SEGMENT')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'BACKUP ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'LOCK ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'COMMENT ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'SELECT ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'INSERT ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'UPDATE ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'DELETE ANY TABLE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE CLUSTER')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY CLUSTER')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY CLUSTER')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY CLUSTER')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY INDEX')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY INDEX')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY INDEX')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE SYNONYM')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY SYNONYM')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY SYNONYM')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE PUBLIC SYNONYM')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP PUBLIC SYNONYM')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE VIEW')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY VIEW')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY VIEW')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE SEQUENCE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('DBA',      'SELECT ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE DATABASE LINK')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE PUBLIC DATABASE LINK')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP PUBLIC DATABASE LINK')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ROLE')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY ROLE')
*
INSERT INTO role_privs VALUES ('DBA',      'GRANT ANY ROLE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY ROLE')
*
INSERT INTO role_privs VALUES ('DBA',      'AUDIT ANY')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER DATABASE')
*
INSERT INTO role_privs VALUES ('DBA',      'FORCE TRANSACTION')
*
INSERT INTO role_privs VALUES ('DBA',      'FORCE ANY TRANSACTION')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE PROCEDURE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('DBA',      'EXECUTE ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE TRIGGER')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY TRIGGER')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY TRIGGER')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY TRIGGER')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE PROFILE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER PROFILE')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP PROFILE')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER RESOURCE COST')
*
INSERT INTO role_privs VALUES ('DBA',      'ANALYZE ANY')
*
INSERT INTO role_privs VALUES ('DBA',      'GRANT ANY PRIVILEGE')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE SNAPSHOT')
*
INSERT INTO role_privs VALUES ('DBA',      'CREATE ANY SNAPSHOT')
*
INSERT INTO role_privs VALUES ('DBA',      'ALTER ANY SNAPSHOT')
*
INSERT INTO role_privs VALUES ('DBA',      'DROP ANY SNAPSHOT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER SYSTEM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'AUDIT SYSTEM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE SESSION')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER SESSION')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'RESTRICTED SESSION')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE TABLESPACE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER TABLESPACE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'MANAGE TABLESPACE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP TABLESPACE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'UNLIMITED TABLESPACE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE USER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'BECOME USER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER USER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP USER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ROLLBACK SEGMENT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ROLLBACK SEGMENT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ROLLBACK SEGMENT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'BACKUP ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'LOCK ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'COMMENT ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'SELECT ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'INSERT ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'UPDATE ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DELETE ANY TABLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE CLUSTER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY CLUSTER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY CLUSTER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY CLUSTER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY INDEX')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY INDEX')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY INDEX')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE SYNONYM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY SYNONYM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY SYNONYM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE PUBLIC SYNONYM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP PUBLIC SYNONYM')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE VIEW')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY VIEW')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY VIEW')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE SEQUENCE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'SELECT ANY SEQUENCE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE DATABASE LINK')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE PUBLIC DATABASE LINK')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP PUBLIC DATABASE LINK')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ROLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY ROLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'GRANT ANY ROLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY ROLE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'AUDIT ANY')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER DATABASE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'FORCE TRANSACTION')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'FORCE ANY TRANSACTION')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE PROCEDURE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'EXECUTE ANY PROCEDURE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE TRIGGER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY TRIGGER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY TRIGGER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY TRIGGER')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE PROFILE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER PROFILE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP PROFILE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER RESOURCE COST')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ANALYZE ANY')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'GRANT ANY PRIVILEGE')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE SNAPSHOT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'CREATE ANY SNAPSHOT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'ALTER ANY SNAPSHOT')
*
INSERT INTO role_privs VALUES ('SYSDBA',   'DROP ANY SNAPSHOT')
*

CREATE VIEW session_privs AS
 SELECT privilege FROM sys.role_privs, sysdd.users
   WHERE users.usermode = role_privs.usermode
     AND users.username = USERGROUP
*
GRANT SELECT ON session_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW session_roles
      (role)
  AS SELECT
       EXPAND (USER, 30)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON session_roles TO PUBLIC WITH GRANT OPTION
*

CREATE TABLE stmt_audit_option_map
      ("OPTION#" FLOAT (18) NOT NULL,
       name      CHAR (40)  NOT NULL
      )
*
GRANT SELECT ON stmt_audit_option_map TO PUBLIC WITH GRANT OPTION
*
INSERT INTO stmt_audit_option_map VALUES (3,   'ALTER SYSTEM')
*
INSERT INTO stmt_audit_option_map VALUES (4,   'SYSTEM AUDIT')
*
INSERT INTO stmt_audit_option_map VALUES (5,   'CREATE SESSION')
*
INSERT INTO stmt_audit_option_map VALUES (6,   'ALTER SESSION')
*
INSERT INTO stmt_audit_option_map VALUES (7,   'RESTRICTED SESSION')
*
INSERT INTO stmt_audit_option_map VALUES (8,   'TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (9,   'CLUSTER')
*
INSERT INTO stmt_audit_option_map VALUES (10,  'CREATE TABLESPACE')
*
INSERT INTO stmt_audit_option_map VALUES (11,  'ALTER TABLESPACE')
*
INSERT INTO stmt_audit_option_map VALUES (12,  'MANAGE TABLESPACE')
*
INSERT INTO stmt_audit_option_map VALUES (13,  'DROP TABLESPACE')
*
INSERT INTO stmt_audit_option_map VALUES (14,  'TABLESPACE')
*
INSERT INTO stmt_audit_option_map VALUES (15,  'UNLIMITED TABLESPACE')
*
INSERT INTO stmt_audit_option_map VALUES (16,  'USER')
*
INSERT INTO stmt_audit_option_map VALUES (17,  'ROLLBACK SEGMENT')
*
INSERT INTO stmt_audit_option_map VALUES (18,  'CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (19,  'INDEX')
*
INSERT INTO stmt_audit_option_map VALUES (20,  'CREATE USER')
*
INSERT INTO stmt_audit_option_map VALUES (21,  'BECOME USER')
*
INSERT INTO stmt_audit_option_map VALUES (22,  'ALTER USER')
*
INSERT INTO stmt_audit_option_map VALUES (23,  'DROP USER')
*
INSERT INTO stmt_audit_option_map VALUES (24,  'SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (25,  'PUBLIC SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (26,  'VIEW')
*
INSERT INTO stmt_audit_option_map VALUES (27,  'SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (28,  'DATABASE LINK')
*
INSERT INTO stmt_audit_option_map VALUES (29,  'PUBLIC DATABASE LINK')
*
INSERT INTO stmt_audit_option_map VALUES (30,  'CREATE ROLLBACK SEGMENT')
*
INSERT INTO stmt_audit_option_map VALUES (31,  'ALTER ROLLBACK SEGMENT')
*
INSERT INTO stmt_audit_option_map VALUES (32,  'DROP ROLLBACK SEGMENT')
*
INSERT INTO stmt_audit_option_map VALUES (33,  'ROLE')
*
INSERT INTO stmt_audit_option_map VALUES (34,  'SET')
*
INSERT INTO stmt_audit_option_map VALUES (35,  'PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (36,  'TRIGGER')
*
INSERT INTO stmt_audit_option_map VALUES (37,  'PROFILE')
*
INSERT INTO stmt_audit_option_map VALUES (40,  'CREATE TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (41,  'CREATE ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (42,  'ALTER ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (43,  'BACKUP ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (44,  'DROP ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (45,  'LOCK ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (46,  'COMMENT ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (47,  'SELECT ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (48,  'INSERT ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (49,  'UPDATE ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (50,  'DELETE ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (53,  'GRANT ANY TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (54,  'ALTER TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (55,  'BACKUP TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (56,  'DROP TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (57,  'LOCK TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (58,  'COMMENT TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (60,  'CREATE CLUSTER')
*
INSERT INTO stmt_audit_option_map VALUES (61,  'CREATE ANY CLUSTER')
*
INSERT INTO stmt_audit_option_map VALUES (62,  'ALTER ANY CLUSTER')
*
INSERT INTO stmt_audit_option_map VALUES (63,  'DROP ANY CLUSTER')
*
INSERT INTO stmt_audit_option_map VALUES (65,  'SELECT TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (66,  'INSERT TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (67,  'UPDATE TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (68,  'DELETE TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (69,  'GRANT TABLE')
*
INSERT INTO stmt_audit_option_map VALUES (70,  'CREATE INDEX')
*
INSERT INTO stmt_audit_option_map VALUES (71,  'CREATE ANY INDEX')
*
INSERT INTO stmt_audit_option_map VALUES (72,  'ALTER ANY INDEX')
*
INSERT INTO stmt_audit_option_map VALUES (73,  'DROP ANY INDEX')
*
INSERT INTO stmt_audit_option_map VALUES (77,  'NOT EXISTS')
*
INSERT INTO stmt_audit_option_map VALUES (80,  'CREATE SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (81,  'CREATE ANY SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (82,  'DROP ANY SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (85,  'CREATE PUBLIC SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (86,  'DROP PUBLIC SYNONYM')
*
INSERT INTO stmt_audit_option_map VALUES (87,  'EXISTS')
*
INSERT INTO stmt_audit_option_map VALUES (90,  'CREATE VIEW')
*
INSERT INTO stmt_audit_option_map VALUES (91,  'CREATE ANY VIEW')
*
INSERT INTO stmt_audit_option_map VALUES (92,  'DROP ANY VIEW')
*
INSERT INTO stmt_audit_option_map VALUES (100, 'GRANT ANY VIEW')
*
INSERT INTO stmt_audit_option_map VALUES (103, 'ALTER SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (104, 'SELECT SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (105, 'CREATE SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (106, 'CREATE ANY SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (107, 'ALTER ANY SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (108, 'DROP ANY SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (109, 'SELECT ANY SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (111, 'GRANT SEQUENCE')
*
INSERT INTO stmt_audit_option_map VALUES (115, 'CREATE DATABASE LINK')
*
INSERT INTO stmt_audit_option_map VALUES (120, 'CREATE PUBLIC DATABASE LINK')
*
INSERT INTO stmt_audit_option_map VALUES (121, 'DROP PUBLIC DATABASE LINK')
*
INSERT INTO stmt_audit_option_map VALUES (125, 'CREATE ROLE')
*
INSERT INTO stmt_audit_option_map VALUES (126, 'DROP ANY ROLE')
*
INSERT INTO stmt_audit_option_map VALUES (127, 'GRANT ANY ROLE')
*
INSERT INTO stmt_audit_option_map VALUES (128, 'ALTER ANY ROLE')
*
INSERT INTO stmt_audit_option_map VALUES (130, 'AUDIT ANY')
*
INSERT INTO stmt_audit_option_map VALUES (131, 'SYSTEM GRANT')
*
INSERT INTO stmt_audit_option_map VALUES (140, 'CREATE PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (141, 'CREATE ANY PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (142, 'ALTER ANY PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (143, 'DROP ANY PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (144, 'EXECUTE ANY PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (145, 'GRANT ANY PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (146, 'EXECUTE PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (147, 'GRANT PROCEDURE')
*
INSERT INTO stmt_audit_option_map VALUES (151, 'CREATE TRIGGER')
*
INSERT INTO stmt_audit_option_map VALUES (152, 'CREATE ANY TRIGGER')
*
INSERT INTO stmt_audit_option_map VALUES (153, 'ALTER ANY TRIGGER')
*
INSERT INTO stmt_audit_option_map VALUES (154, 'DROP ANY TRIGGER')
*
INSERT INTO stmt_audit_option_map VALUES (155, 'TRUNCATE')
*
INSERT INTO stmt_audit_option_map VALUES (160, 'CREATE PROFILE')
*
INSERT INTO stmt_audit_option_map VALUES (161, 'ALTER PROFILE')
*
INSERT INTO stmt_audit_option_map VALUES (162, 'DROP PROFILE')
*
INSERT INTO stmt_audit_option_map VALUES (163, 'ALTER RESOURCE COST')
*
INSERT INTO stmt_audit_option_map VALUES (165, 'ANALYZE ANY')
*
INSERT INTO stmt_audit_option_map VALUES (170, 'CREATE SNAPSHOT')
*
INSERT INTO stmt_audit_option_map VALUES (171, 'ALTER SNAPSHOT')
*
INSERT INTO stmt_audit_option_map VALUES (172, 'DROP SNAPSHOT')
*
INSERT INTO stmt_audit_option_map VALUES (173, 'CREATE ANY SNAPSHOT')
*
INSERT INTO stmt_audit_option_map VALUES (174, 'ALTER ANY SNAPSHOT')
*
INSERT INTO stmt_audit_option_map VALUES (175, 'DROP ANY SNAPSHOT')
*
INSERT INTO stmt_audit_option_map VALUES (176, 'CREATE CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (177, 'CREATE ANY CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (178, 'ALTER ANY CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (179, 'DROP ANY CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (180, 'LOCK ANY CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (181, 'COMMENT ANY CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (182, 'GRANT ANY CLASS')
*
INSERT INTO stmt_audit_option_map VALUES (183, 'CREATE SET')
*
INSERT INTO stmt_audit_option_map VALUES (184, 'CREATE ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (185, 'ALTER ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (186, 'BACKUP ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (187, 'DROP ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (188, 'LOCK ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (189, 'SELECT ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (190, 'INSERT ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (191, 'UPDATE ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (192, 'DELETE ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (193, 'GRANT ANY SET')
*
INSERT INTO stmt_audit_option_map VALUES (197, 'READUP')
*
INSERT INTO stmt_audit_option_map VALUES (198, 'WRITEDOWN')
*
INSERT INTO stmt_audit_option_map VALUES (199, 'WRITEUP')
*

CREATE VIEW table_privileges
      (grantee, owner, table_name, grantor,
       select_priv, insert_priv, delete_priv, update_priv,
       references_priv, alter_priv, index_priv,
       created)
    AS SELECT
        EXPAND (grantee, 30),
        EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (grantor, 30),
        DECODE (INDEX (privileges, 'SEL'), 0, 'N', 'Y'),
        DECODE (INDEX (privileges, 'INS'), 0, 'N', 'Y'),
        DECODE (INDEX (privileges, 'DEL'), 0, 'N', 'Y'),
        DECODE (INDEX (privileges, 'UPD'), 0, 'N', 'Y'),
        DECODE (INDEX (privileges, 'REF'), 0, 'N', 'Y'),
        DECODE (INDEX (privileges, 'ALT'), 0, 'N', 'Y'),
        DECODE (INDEX (privileges, 'IND'), 0, 'N', 'Y'),
        TIMESTAMP ("DATE", "TIME")
    FROM sysdd.privileges
       WHERE name2 IS NULL AND grantee <> grantor
*
GRANT ALL ON table_privileges TO PUBLIC WITH GRANT OPTION
*

CREATE TABLE table_privilege_map
      (privilege FLOAT (18) PRIMARY KEY,
       name      CHAR (40)  NOT NULL
      )
*
GRANT SELECT ON table_privilege_map TO PUBLIC WITH GRANT OPTION
*
 INSERT INTO table_privilege_map VALUES (0,  'ALTER')
*
 INSERT INTO table_privilege_map VALUES (1,  'AUDIT')
*
 INSERT INTO table_privilege_map VALUES (2,  'COMMENT')
*
 INSERT INTO table_privilege_map VALUES (3,  'DELETE')
*
 INSERT INTO table_privilege_map VALUES (4,  'GRANT')
*
 INSERT INTO table_privilege_map VALUES (5,  'INDEX')
*
 INSERT INTO table_privilege_map VALUES (6,  'INSERT')
*
 INSERT INTO table_privilege_map VALUES (7,  'LOCK')
*
 INSERT INTO table_privilege_map VALUES (8,  'RENAME')
*
 INSERT INTO table_privilege_map VALUES (9,  'SELECT')
*
 INSERT INTO table_privilege_map VALUES (10, 'UPDATE')
*
 INSERT INTO table_privilege_map VALUES (11, 'REFERENCES')
*
 INSERT INTO table_privilege_map VALUES (12, 'EXECUTE')
*

CREATE VIEW user_audit_trail
      (os_username, username, userhost, terminal, "TIMESTAMP",
       owner, obj_name, action, action_name, new_owner, new_name,
       obj_privilege, sys_privilege, admin_option, grantee, audit_option,
       ses_actions, logoff_time, logoff_lread, logoff_pread,
       logoff_lwrite, logoff_dlock, comment_text, sessionid, entryid,
       statementid, returncode, priv_used, object_label, session_label)
  AS SELECT EXPAND (' ', 254),
            EXPAND (' ',  30),
            EXPAND (' ', 254),
            EXPAND (' ', 254),
            TIMESTAMP (DATE, TIME),
            EXPAND (' ',  30),
            EXPAND (' ', 128),
            0,
            aa.name,
            EXPAND (' ',  30),
            EXPAND (' ', 128),
            EXPAND (' ',  16),
            EXPAND (' ',  40),
	    'N',
	    EXPAND (' ',  30),
            EXPAND (' ',  40),
            EXPAND (' ',  16),
            TIMESTAMP (DATE, TIME),
            0,
            0,
            0,
            EXPAND (' ',  40),
            EXPAND (' ', 254),
            0,
            0,
            0,
            0,
            EXPAND (' ',  40),
            NULL,
            NULL
        FROM dual, audit_actions aa
        WHERE 0 = 1 AND 0 = aa.action
*
GRANT ALL ON user_audit_trail TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_audit_object
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            owner, obj_name, action_name, new_owner, new_name,
            ses_actions, comment_text, sessionid, entryid, statementid,
            returncode, priv_used, object_label, session_label
       FROM user_audit_trail
       WHERE action BETWEEN   1 AND  16
          OR action BETWEEN  19 AND  29
          OR action BETWEEN  32 AND  41
          OR action = 43
          OR action BETWEEN  51 AND  99
          OR action = 103
          OR action BETWEEN 110 AND 113
          OR action BETWEEN 116 AND 121
*
GRANT ALL ON user_audit_object TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_audit_session
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            action_name, logoff_time, logoff_lread, logoff_pread,
            logoff_lwrite, logoff_dlock,
            sessionid, returncode, session_label
       FROM user_audit_trail
       WHERE action BETWEEN 100 AND 102
*
GRANT ALL ON user_audit_session TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_audit_statement
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            owner, obj_name, action_name, new_name, obj_privilege,
            sys_privilege, admin_option, grantee, audit_option,
            ses_actions, comment_text, sessionid, entryid,
            statementid, returncode, priv_used, session_label
       FROM user_audit_trail
       WHERE action IN (17, 18, 30, 31, 49, 104,
                        105, 106, 107, 108, 109, 114, 115)
*
GRANT ALL ON user_audit_statement TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_catalog
    AS SELECT table_name, table_type
         FROM all_catalog
           WHERE owner = USERGROUP
*
GRANT ALL ON user_catalog TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_clusters
      (cluster_name, tablespace_name,
       pct_free, pct_used, key_size, ini_trans, max_trans,
       initial_extent, next_extent, min_extents, max_extents, pct_increase,
       avg_blocks_per_key, cluster_type, function, hashkeys)
    AS SELECT
        EXPAND (' ',  30),
        'SYSTEM                        ',
        0,
        0,
        0,
        0,
        999999999999999999,
        0,
        0,
        0,
        999999999999999999,
        0,
        0,
        EXPAND (' ', 5),
        EXPAND (' ', 7),
	0
    FROM dual
       WHERE 1 = 0
*
GRANT ALL ON user_clusters TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_clu_columns
      (cluster_name, clu_column_name, table_name, tab_column_name)
    AS SELECT
            EXPAND (' ',  30),
            EXPAND (' ',  30),
            EXPAND (' ',  30),
            EXPAND (' ',  30)
    FROM dual
       WHERE 1 = 0
*
GRANT ALL ON user_clu_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_col_comments
    AS SELECT table_name, column_name, comments
          FROM all_col_comments
           WHERE owner = USERGROUP
*
GRANT ALL ON user_col_comments TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_col_privs
      (grantee, owner, table_name, column_name, grantor,
       privilege, grantable)
  AS SELECT
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (name2,   30),
        EXPAND (grantor, 30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NOT NULL AND grantor <> grantee
       AND (owner = USERGROUP OR grantor = USERGROUP OR grantee = USERGROUP)
*
GRANT ALL ON user_col_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_col_privs_made
   AS SELECT grantee, table_name, column_name, grantor, privilege, grantable
        FROM all_col_privs_made
        WHERE owner = USERGROUP
*
GRANT ALL ON user_col_privs_made TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_col_privs_recd
   AS SELECT owner, table_name, column_name, grantor, privilege, grantable
        FROM all_col_privs_recd
        WHERE grantee = USERGROUP
*
GRANT ALL ON user_col_privs_recd TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_constraints
   AS SELECT *
        FROM all_constraints
        WHERE owner = USERGROUP
*
GRANT ALL ON user_constraints TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_cons_columns
   AS SELECT *
        FROM all_cons_columns
        WHERE owner = USERGROUP
*
GRANT ALL ON user_cons_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_db_links
      (db_link, username, password, host, created)
   AS SELECT EXPAND (' ',  30),
             EXPAND (' ',  30),
             EXPAND (' ',  30),
             EXPAND (' ', 254),
             TIMESTAMP (DATE, TIME)
        FROM dual
        WHERE 0 = 1
*
GRANT ALL ON user_db_links TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_dependencies
  AS SELECT name, type, referenced_owner, referenced_name, referenced_type,
            referenced_link_name
       FROM all_dependencies
       WHERE owner = USERGROUP
*
GRANT ALL ON user_dependencies TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_errors
  AS SELECT name, type, sequence, line, position, text
       FROM all_errors
       WHERE owner = USERGROUP
*
GRANT ALL ON user_errors TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_extents
      (segment_name, segment_type, tablespace_name, extent_id, bytes, blocks)
   AS SELECT
        EXPAND (' ', 81),
        EXPAND (' ', 17),
	'SYSTEM                        ',
        0,
        0,
        0
        FROM dual
        WHERE 0 = 1
*
GRANT ALL ON user_extents TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_free_space
      (tablespace_name, file_id, block_id, bytes, blocks)
   AS SELECT
	'SYSTEM                        ',
        0,
        0,
        0,
        0
        FROM dual
        WHERE 0 = 1
*
GRANT ALL ON user_free_space TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_indexes
   AS SELECT index_name, table_owner, table_name, table_type,
             uniqueness, tablespace_name, ini_trans, max_trans,
             initial_extent, next_extent, min_extents, max_extents,
             pct_increase, pct_free, blevel, leaf_blocks, distinct_keys,
	     avg_leaf_blocks_per_key, avg_data_blocks_per_key,
	     clustering_factor, status
        FROM all_indexes
        WHERE table_owner = USERGROUP
*
GRANT ALL ON user_indexes TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_ind_columns
   AS SELECT index_name, table_name,
             column_name, column_position, column_length
        FROM all_ind_columns
        WHERE table_owner = USERGROUP
*
GRANT ALL ON user_ind_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_objects
      (object_name, object_id, object_type, created, last_ddl_time,
       "TIMESTAMP", status)
    AS SELECT
        object_name,
        object_id,
        EXPAND (object_type, 13),
        created,
        last_ddl_time,
	"TIMESTAMP",
	status
      FROM all_objects
      WHERE owner = USERGROUP
*
GRANT ALL ON user_objects TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_object_size
      (name, type, source_size, parsed_size, code_size, error_size)
  AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 12),
       0,
       0,
       0,
       0
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON user_object_size TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_obj_audit_opts
      (object_name, object_type,
       alt, aud, com, del, gra, ind, ins, loc, ren, sel, upd, ref, exe)
    AS SELECT
        EXPAND (tablename, 30),
        'TABLE',
        '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-',
        '-/-', '-/-', '-/-', '-/-', '-/-'
     FROM sysdd.tables
       WHERE type = 'TABLE' AND owner = USERGROUP
    UNION ALL SELECT
        EXPAND (tablename, 30),
        'VIEW  ',
        '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-',
        '-/-', '-/-', '-/-', '-/-', '-/-'
     FROM sysdd.views
       WHERE owner = USERGROUP
*
GRANT ALL ON user_obj_audit_opts TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_resource_limits
      (resource_name, limit)
  AS SELECT
       EXPAND (' ', 32),
       EXPAND (' ', 40)
     FROM dual
*
GRANT ALL ON user_resource_limits TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_role_privs
      (username, granted_role, admin_option, default_role, os_granted)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (USER, 30),
       'NO ',
       'NO ',
       'NO '
     FROM dual
*
GRANT ALL ON user_role_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_segments
      (segment_name, segment_type, tablespace_name, bytes, blocks,
       extents, initial_extent, next_extent, min_extents, max_extents,
       pct_increase, freelists, freelist_groups)
    AS SELECT
        EXPAND (tablename, 81),
        'TABLE            ',
        'SYSTEM                        ',
        FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL)
    FROM sysdd.tables
    WHERE owner = USERGROUP AND type = 'TABLE'
*
GRANT ALL ON user_segments TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_sequences
    AS SELECT sequence_name, min_value, max_value, increment_by,
                  cycle_flag, order_flag, cache_size, last_number
         FROM all_sequences
         WHERE sequence_owner = USERGROUP
*
GRANT ALL ON user_sequences TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_snapshots
    AS SELECT * FROM all_snapshots
         WHERE owner = USERGROUP
*
GRANT ALL ON user_snapshots TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_snapshot_logs
      (log_owner, master, log_table, log_trigger, current_snapshots)
  AS SELECT
       EXPAND (owner,                 30),
       EXPAND (tablename,             30),
       EXPAND ('MLOG$_' || tablename, 30),
       EXPAND (NULL, 30),
       TIMESTAMP (NULL, NULL)
     FROM sysdd.tables
     WHERE snapshot_log = 'YES'
*
GRANT ALL ON user_snapshot_logs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_source
  AS SELECT name, type, line, text
     FROM all_source
     WHERE owner = USERGROUP
*
GRANT ALL ON user_source TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_synonyms
      (synonym_name, table_owner, table_name, db_link)
    AS SELECT
        EXPAND (synonymname, 30),
        EXPAND (owner,       30),
        EXPAND (tablename,   30),
        EXPAND (NULL,        30)
    FROM sysdd.synonyms
*
GRANT ALL ON user_synonyms TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_sys_privs
      (username, privilege, admin_option)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  40),
       'NO '
     FROM dual
       WHERE 0 = 1
*
GRANT ALL ON user_sys_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tables
     AS SELECT table_name, tablespace_name, cluster_name,
                 pct_free, pct_used, ini_trans, max_trans,
               initial_extent, next_extent, min_extents, max_extents,
               pct_increase, backed_up, num_rows, blocks, empty_blocks,
	       avg_space, chain_cnt, avg_row_len
          FROM all_tables
          WHERE owner = USERGROUP
*
GRANT ALL ON user_tables TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tablespaces
      (tablespace_name, initial_extent, next_extent, min_extents, max_extents,
       pct_increase, status)
   AS SELECT
	'SYSTEM                        ',
        0,
        0,
        0,
        999999999999999999,
        0,
        EXPAND (' ', 9)
        FROM dual
        WHERE 0 = 1
*
GRANT ALL ON user_tablespaces TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tab_columns
    AS SELECT table_name, column_name, data_type, data_length,
                data_precision, data_scale, nullable, column_id,
                default_length, data_default,
		num_distinct, low_value, high_value, density
         FROM all_tab_columns
         WHERE owner = USERGROUP
*
GRANT ALL ON user_tab_columns TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tab_comments
    AS SELECT table_name, table_type, comments
          FROM all_tab_comments
         WHERE owner = USERGROUP
*
GRANT ALL ON user_tab_comments TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tab_privs
      (grantee, owner, table_name, grantor, privilege, grantable)
  AS SELECT
	EXPAND (grantee, 30),
	EXPAND (owner,   30),
        EXPAND (name1,   30),
        EXPAND (grantor, 30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
     FROM sysdd.new_privileges
     WHERE name2 IS NULL AND grantor <> grantee
       AND owner = USERGROUP OR grantor = USERGROUP OR grantee = USERGROUP
*
GRANT ALL ON user_tab_privs TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tab_privs_made
    AS SELECT grantee, table_name, grantor, privilege, grantable
         FROM all_tab_privs_made
         WHERE owner = USERGROUP
*
GRANT ALL ON user_tab_privs_made TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_tab_privs_recd
    AS SELECT owner, table_name, grantor, privilege, grantable
         FROM all_tab_privs_recd
         WHERE grantee = USERGROUP
*
GRANT ALL ON user_tab_privs_recd TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_triggers
  AS SELECT trigger_name, trigger_type, triggering_event,
            table_owner, table_name, referencing_names, when_clause,
            status, description, trigger_body
       FROM all_triggers
       WHERE owner = USERGROUP
*
GRANT ALL ON user_triggers TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_trigger_cols
  AS SELECT * FROM all_trigger_cols
       WHERE trigger_owner = USERGROUP OR table_owner = USERGROUP
*
GRANT ALL ON user_trigger_cols TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_ts_quotas
      (tablespace_name, bytes, max_bytes, blocks, max_blocks)
   AS SELECT
	'SYSTEM                        ',
        0,
        999999999999999999,
        0,
        999999999999999999
        FROM dual
        WHERE 0 = 1
*
GRANT ALL ON user_ts_quotas TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_users
      (username, user_id, default_tablespace, temporary_tablespace, created)
    AS SELECT
        EXPAND (username, 30),
        user_id,
        'SYSTEM                        ',
        'SYSTEM                        ',
        TIMESTAMP ("DATE", "TIME")
    FROM sysdd.users
       WHERE username = USERGROUP
*
GRANT ALL ON user_users TO PUBLIC WITH GRANT OPTION
*

CREATE VIEW user_views
    AS SELECT view_name, text_length, text
         FROM all_views
         WHERE owner = USERGROUP
*
GRANT ALL ON user_views TO PUBLIC WITH GRANT OPTION
*


*
* =================================
* Part 2) DBA Data Dictionary Views
* =================================
*
* The following data dictionary views are restricted. They can be accessed
* only by users with the dba privilege
*

CREATE VIEW dba_2pc_neighbors
      (local_tran_id, in_out, "DATABASE", dbuser_owner,
       interface, dbid, "SESS#", branch)
  AS SELECT
       EXPAND (' ',  22),
       'OUT',
       EXPAND (' ', 128),
       EXPAND (' ',  30),
       'N',
       EXPAND (' ',  16),
       0,
       EXPAND (' ', 128)
     FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_2pc_neighbors TO PUBLIC
*

CREATE VIEW dba_2pc_pending
    (local_tran_id, global_tran_id, state, mixed, advice, tran_comment,
     fail_time, force_time, retry_time, os_user, os_terminal,
     host, db_user, "COMMIT#")
  AS SELECT
       EXPAND (' ',  22),
       EXPAND (' ', 169),
       EXPAND (' ',  16),
       EXPAND (' ',   3),
       'C',
       EXPAND (' ',  254),
       TIMESTAMP (DATE, TIME),
       TIMESTAMP (DATE, TIME),
       TIMESTAMP (DATE, TIME),
       EXPAND (' ',  254),
       EXPAND (' ',  254),
       EXPAND (' ',  254),
       EXPAND (USER,  30),
       EXPAND (' ',   16)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_2pc_pending TO PUBLIC
*

CREATE VIEW dba_audit_trail
      (os_username, username, userhost, terminal, "TIMESTAMP",
       owner, obj_name, action, action_name, new_owner, new_name,
       obj_privilege, sys_privilege, admin_option, grantee, audit_option,
       ses_actions, logoff_time, logoff_lread, logoff_pread,
       logoff_lwrite, logoff_dlock, comment_text, sessionid, entryid,
       statementid, returncode, priv_used, object_label, session_label)
  AS SELECT EXPAND (' ', 254),
            EXPAND (' ',  30),
            EXPAND (' ', 254),
            EXPAND (' ', 254),
            TIMESTAMP (DATE, TIME),
            EXPAND (' ',  30),
            EXPAND (' ', 128),
            0,
            aa.name,
            EXPAND (' ',  30),
            EXPAND (' ', 128),
            EXPAND (' ',  16),
            EXPAND (' ',  40),
	    'N',
	    EXPAND (' ',  30),
            EXPAND (' ',  40),
            EXPAND (' ',  16),
            TIMESTAMP (DATE, TIME),
            0,
            0,
            0,
            EXPAND (' ',  40),
            EXPAND (' ', 254),
            0,
            0,
            0,
            0,
            EXPAND (' ',  40),
            NULL,
            NULL
        FROM dual, audit_actions aa
        WHERE 0 = 1 AND 0 = aa.action
*
GRANT ALL ON dba_audit_trail TO PUBLIC
*

CREATE VIEW dba_audit_exists
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            owner, obj_name, action_name, new_owner, new_name,
            obj_privilege, sys_privilege, grantee,
            sessionid, entryid, statementid, returncode
       FROM dba_audit_trail
       WHERE returncode IN (942, 943, 959, 1418, 1432, 1434, 1435,
                            1534, 1917, 1918, 1919, 2019, 2024, 2289,
                            4042, 4043, 4080, 1, 951, 955, 957, 1430,
                            1433, 1452, 1471, 1535, 1543, 1758, 1920,
                            1921, 1922, 2239, 2264, 2266, 2273, 2292,
                            2297, 2378, 2379, 2382, 4081, 12006, 12325)
*
GRANT ALL ON dba_audit_exists TO PUBLIC
*

CREATE VIEW dba_audit_object
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            owner, obj_name, action_name, new_owner, new_name,
            ses_actions, comment_text, sessionid, entryid, statementid,
            returncode, priv_used, object_label, session_label
       FROM dba_audit_trail
       WHERE action BETWEEN   1 AND  16
          OR action BETWEEN  19 AND  29
          OR action BETWEEN  32 AND  41
          OR action = 43
          OR action BETWEEN  51 AND  99
          OR action = 103
          OR action BETWEEN 110 AND 113
          OR action BETWEEN 116 AND 121
*
GRANT ALL ON dba_audit_object TO PUBLIC
*

CREATE VIEW dba_audit_session
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            action_name, logoff_time, logoff_lread, logoff_pread,
            logoff_lwrite, logoff_dlock, sessionid, returncode, session_label
       FROM dba_audit_trail
       WHERE action BETWEEN 100 AND 102
*
GRANT ALL ON dba_audit_session TO PUBLIC
*

CREATE VIEW dba_audit_statement
  AS SELECT os_username, username, userhost, terminal, "TIMESTAMP",
            owner, obj_name, action_name, new_name, obj_privilege,
            sys_privilege, admin_option, grantee, audit_option,
            ses_actions, comment_text, sessionid, entryid, statementid,
            returncode, priv_used, session_label
       FROM dba_audit_trail
       WHERE action IN (17, 18, 30, 31, 49, 104, 105,
                        106, 107, 108, 109, 114, 115)
*
GRANT ALL ON dba_audit_statement TO PUBLIC
*

CREATE VIEW dba_blockers
      (session_id)
  AS SELECT 0 FROM dual WHERE 0 = 1
*
GRANT ALL ON dba_blockers TO PUBLIC
*

CREATE VIEW dba_catalog
      (owner, table_name, table_type)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        EXPAND (type,      11)
    FROM sysdd.db_tables
  UNION ALL SELECT
        EXPAND (owner,         30),
        EXPAND (sequence_name, 30),
        'SEQUENCE   '
    FROM sysdd.db_sequences
*
GRANT ALL ON dba_catalog TO PUBLIC
*

CREATE VIEW dba_clusters
      (owner, cluster_name, tablespace_name,
       pct_free, pct_used, key_size, ini_trans, max_trans,
       initial_extent, next_extent, min_extents, max_extents, pct_increase,
       avg_blocks_per_key, cluster_type, function, hashkeys)
    AS SELECT
        EXPAND (' ', 30),
        EXPAND (' ', 30),
	'SYSTEM                        ',
        0, 0, 0, 0, 999999999999999999,
        0, 0, 0,    999999999999999999, 0,
        0,
        EXPAND (' ', 5),
        EXPAND (' ', 7),
	0
    FROM dual
       WHERE 1 = 0
*
GRANT ALL ON dba_clusters TO PUBLIC
*

CREATE VIEW dba_clu_columns
      (owner, cluster_name, clu_column_name, table_name, tab_column_name)
    AS SELECT
        EXPAND (' ', 30),
        EXPAND (' ', 30),
        EXPAND (' ', 30),
        EXPAND (' ', 30),
        EXPAND (' ', 30)
    FROM dual
       WHERE 1 = 0
*
GRANT ALL ON dba_clu_columns TO PUBLIC
*

CREATE VIEW dba_col_comments
       (owner, table_name, column_name, comments)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        EXPAND (columnname, 30),
        comment_c
    FROM sysdd.db_columns
*
GRANT ALL ON dba_col_comments TO PUBLIC
*

CREATE VIEW dba_col_privs
      (grantee, owner, table_name, column_name, grantor, privilege, grantable)
    AS SELECT
        EXPAND (grantee,    30),
        EXPAND (owner,      30),
        EXPAND (name1,      30),
        EXPAND (name2,      30),
        EXPAND (grantor,    30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
    FROM sysdd.db_new_privileges
       WHERE name2 IS NOT NULL
*
GRANT ALL ON dba_col_privs TO PUBLIC
*

CREATE VIEW dba_constraints
      (owner, constraint_name, constraint_type, table_name,
       search_condition, r_owner, r_constraint_name, delete_rule, status)
    AS SELECT
        EXPAND (owner,          30),
        EXPAND (constraintname, 30),
        'C ',
        EXPAND (tablename,      30),
        definition_c,
        EXPAND (NULL, 30),
        EXPAND (NULL, 30),
        EXPAND (NULL, 10),
        'ENABLED '
    FROM sysdd.db_constraints
UNION ALL SELECT
       EXPAND (owner,         30),
       'C' || tablename || CHR (columnno),
       'C ',
       EXPAND (tablename,     30),
       columnname || ' IS NOT NULL',
       EXPAND (NULL, 30),
       EXPAND (NULL, 30),
       EXPAND (NULL, 10),
       'ENABLED '
   FROM sysdd.db_columns
   WHERE mod = 'MAN'
UNION ALL SELECT
       EXPAND (owner,     30),
       'P' || tablename || CHR (keycolumnno),
       'P ',
       EXPAND (tablename,  30),
       EXPAND (columnname, 30),
       EXPAND (NULL,       30),
       EXPAND (NULL,       30),
       EXPAND (NULL,       10),
       'ENABLED '
  FROM sysdd.db_columns
  WHERE keycolumnno IS NOT NULL
UNION ALL SELECT
       EXPAND (owner,      30),
       EXPAND (refname,    30),
       'R ',
       EXPAND (tablename,  30),
       EXPAND (columnname, 30),
       EXPAND (refowner,   30),
       EXPAND (NULL,       30),
       DECODE (rule, 'DELETE CASCADE',  'CASCADE',
                     'DELETE RESTRICT', 'NO ACTION',
                                        rule),
       'ENABLED '
  FROM sysdd.db_foreign_keys
*
GRANT ALL ON dba_constraints TO PUBLIC
*

CREATE VIEW dba_cons_columns
      (owner, constraint_name, table_name, column_name, position)
    AS SELECT
        EXPAND (owner,          30),
        EXPAND (constraintname, 30),
        EXPAND (tablename,      30),
        EXPAND (columnname,     30),
        DECODE (type, 'CHECK', NULL, columnno)
       FROM sysdd.db_constraintcols
*
GRANT ALL ON dba_cons_columns TO PUBLIC
*

CREATE VIEW dba_data_files
      (file_name, file_id, tablespace_name, bytes, blocks, status)
    AS SELECT
       EXPAND (' ', 72),
       1,
	'SYSTEM                        ',
       0, 0,
       'AVAILABLE'
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_data_files TO PUBLIC
*

CREATE VIEW dba_db_links
      (owner, db_link, username, password, host, created)
    AS SELECT
        EXPAND (' ',  30),
        EXPAND (' ',  30),
        EXPAND (' ',  30),
        EXPAND (' ',  30),
        EXPAND (' ', 254),
        TIMESTAMP (DATE, TIME)
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_db_links TO PUBLIC
*

CREATE VIEW dba_ddl_locks
      (session_id, owner, name, type, mode_held, mode_requested)
  AS SELECT
       0,
       EXPAND (USER, 30),
       ' ',
       ' ',
       'NONE      ',
       'EXCLUSIVE '
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_ddl_locks TO PUBLIC
*

CREATE VIEW dba_dependencies
      (owner, name, type,
       referenced_owner, referenced_name, referenced_type,
       referenced_link_name)
  AS SELECT
       EXPAND (owner,        30),
       EXPAND (tablename,    30),
       'VIEW        ',
       EXPAND (refname,      30),
       EXPAND (reftablename, 30),
       'TABLE       ',
       EXPAND (NULL, 30)
     FROM sysdd.db_view_uses_table
*
GRANT ALL ON dba_dependencies TO PUBLIC
*

CREATE VIEW dba_dml_locks
      (session_id, owner, name, mode_held, mode_requested)
  AS SELECT
       0,
       EXPAND (USER, 30),
       ' ',
       'NONE      ',
       'EXCLUSIVE '
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_dml_locks TO PUBLIC
*

CREATE VIEW dba_errors
       (owner, name, type, sequence, line, position, text)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  12),
       999, 1, 1,
       EXPAND (' ',  200)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_errors TO PUBLIC
*

CREATE VIEW dba_exp_files
      (exp_version, exp_type, file_name, user_name, "TIMESTAMP")
    AS SELECT
       0,
       'CUMULATIVE',
       EXPAND (' ', 72),
       EXPAND (' ', 30),
       TIMESTAMP (DATE, TIME)
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_exp_files TO PUBLIC
*

CREATE VIEW dba_exp_objects
      (owner, object_name, object_type,
       cumulative, incremental, export_version)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  12),
       TIMESTAMP (DATE, TIME),
       TIMESTAMP (DATE, TIME),
       0
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_exp_objects TO PUBLIC
*

CREATE VIEW dba_exp_version
  AS SELECT 0 exp_version FROM dual
*
GRANT ALL ON dba_exp_version TO PUBLIC
*

CREATE VIEW dba_extents
      (owner, segment_name, segment_type, tablespace_name,
       extent_id, file_id, block_id, bytes, blocks)
    AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 72),
       EXPAND (' ', 17),
       'SYSTEM                        ',
       0,
       0,
       0,
       0,
       0
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_extents TO PUBLIC
*

CREATE VIEW dba_free_space
      (tablespace_name, file_id, block_id, bytes, blocks)
    AS SELECT
       'SYSTEM                        ',
       0,
       1,
       0,
       0
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_free_space TO PUBLIC
*

CREATE VIEW dba_indexes
      (owner, index_name, table_owner, table_name, table_type,
       uniqueness, tablespace_name, ini_trans, max_trans,
       initial_extent, next_extent, min_extents, max_extents,
       pct_increase, pct_free, blevel, leaf_blocks, distinct_keys,
       avg_leaf_blocks_per_key, avg_data_blocks_per_key,
       clustering_factor, status)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (indexname, 30),
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        'TABLE      ',
        DECODE (type, ' ', 'NONUNIQUE', type),
	'SYSTEM                        ',
        FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	distinctvalues,
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	'VALID      '
    FROM sysdd.db_indexes
      where indexname <> ' ' AND columnno = 1
*
GRANT ALL ON dba_indexes TO PUBLIC
*

create view dba_ind_columns
      (index_owner, index_name, table_owner, table_name,
       column_name, column_position, column_length)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (indexname,  30),
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        EXPAND (columnname, 30),
        columnno,
        DECODE (datatype, 'NUMBER', 22,
                          'FLOAT',  22,
                          'DATE',   7,
                          'LONG',   28,
                                    len)
    FROM sysdd.db_indexes
      WHERE indexname <> ' '
*
GRANT ALL ON dba_ind_columns TO PUBLIC
*

CREATE VIEW dba_locks
      (session_id, type, mode_held, mode_requested, lock_id1, lock_id2)
  AS SELECT
       0,
       'LS',
       'NONE',
       'NONE',
       0,
       0
     FROM dual WHERE 0 = 1
*
GRANT ALL ON dba_locks TO PUBLIC
*

CREATE VIEW dba_objects
      (owner, object_name, object_id, object_type, created,
       last_ddl_time, "TIMESTAMP", status)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        tableid,
        EXPAND (type,       11),
        TIMESTAMP ("DATE", "TIME"),
        VALUE (TIMESTAMP (alterdate, altertime),
               TIMESTAMP ("DATE",    "TIME")),
        SUBSTR (CHAR ("DATE"), 1, 4) || '-' ||
        SUBSTR (CHAR ("DATE"), 5, 2) || '-' ||
        SUBSTR (CHAR ("DATE"), 7, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 3, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 5, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 7, 2),
	'VALID  '
    FROM sysdd.db_tables
  UNION ALL
    SELECT
        EXPAND (owner,         30),
        EXPAND (sequence_name, 30),
        NO,
        'SEQUENCE',
        TIMESTAMP ("DATE", "TIME"),
        TIMESTAMP ("DATE", "TIME"),
        SUBSTR (CHAR ("DATE"), 1, 4) || '-' ||
        SUBSTR (CHAR ("DATE"), 5, 2) || '-' ||
        SUBSTR (CHAR ("DATE"), 7, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 3, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 5, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 7, 2),
	'VALID  '
      FROM sysdd.db_sequences
  UNION ALL
    SELECT
        EXPAND (owner,     30),
        EXPAND (indexname, 30),
        NULL,
        'INDEX',
        TIMESTAMP ("DATE", "TIME"),
        TIMESTAMP ("DATE", "TIME"),
        SUBSTR (CHAR ("DATE"), 1, 4) || '-' ||
        SUBSTR (CHAR ("DATE"), 5, 2) || '-' ||
        SUBSTR (CHAR ("DATE"), 7, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 3, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 5, 2) || ':' ||
        SUBSTR (CHAR ("TIME"), 7, 2),
	'VALID  '
      FROM sysdd.db_indexes
      WHERE columnno = 1
*
GRANT ALL ON dba_objects TO PUBLIC
*

CREATE VIEW dba_object_size
      (owner, name, type, source_size, parsed_size, code_size, error_size)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ', 30),
       EXPAND (' ', 12),
       0,
       0,
       0,
       0
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_object_size TO PUBLIC
*

CREATE VIEW dba_obj_audit_opts
      (owner, object_name, object_type,
       alt, aud, com, del, gra, ind, ins, loc, ren, sel, upd, ref, exe)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        'TABLE      ',
        '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-',
        '-/-', '-/-', '-/-', '-/-', '-/-'
     FROM sysdd.db_tables
        WHERE type = 'TABLE'
    UNION ALL SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        'VIEW       ',
        '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-', '-/-',
        '-/-', '-/-', '-/-', '-/-', '-/-'
    FROM sysdd.db_views
*
GRANT ALL ON dba_obj_audit_opts TO PUBLIC
*

CREATE VIEW dba_priv_audit_opts
      (user_name, privilege, success, failure)
  AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 40),
       EXPAND (' ', 10),
       EXPAND (' ', 10)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_priv_audit_opts TO PUBLIC
*

CREATE VIEW dba_profiles
      (profile, resource_name, limit)
  AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 32),
       EXPAND (' ', 40)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_profiles TO PUBLIC
*

CREATE VIEW dba_roles
      (role, password_required)
  AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 8)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_roles TO PUBLIC
*

CREATE VIEW dba_role_privs
      (grantee, granted_role, admin_option, default_role)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (USER, 30),
       'NO ',
       'NO '
     FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_role_privs TO PUBLIC
*

CREATE VIEW dba_rollback_segs
      (segment_name, owner, tablespace_name, segment_id, file_id, block_id,
       initial_extent, next_extent, min_extents, max_extents,
       pct_increase, status, instance_num)
    AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       'SYSTEM                        ',
       0,
       0,
       0,
       0,
       0,
       0,
       0,
       0,
       ' ',
       0
    FROM dual
       WHERE 0 = 1
*
GRANT ALL ON dba_rollback_segs TO PUBLIC
*

CREATE VIEW dba_segments
      (owner, segment_name, segment_type, tablespace_name,
       header_file, header_block, bytes, blocks, extents,
       initial_extent, next_extent, min_extents, max_extents,
       pct_increase, freelists, freelist_groups)
    AS SELECT
        EXPAND (owner, 30),
        EXPAND (tablename, 81),
        'TABLE            ',
        'SYSTEM                        ',
        FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL)
    FROM sysdd.db_tables
    WHERE type = 'TABLE'
*
GRANT ALL ON dba_segments TO PUBLIC
*

CREATE VIEW dba_sequences
      (sequence_owner, sequence_name, min_value, max_value, increment_by,
       cycle_flag, order_flag, cache_size, last_number)
    AS SELECT
        EXPAND (owner,         30),
        EXPAND (sequence_name, 30),
        min_value,
        max_value,
        increment_by,
        cycle_flag,
        order_flag,
        cache_size,
        last_number
    FROM sysdd.db_sequences
*
GRANT ALL ON dba_sequences TO PUBLIC
*

CREATE VIEW dba_snapshots
       (owner, name, table_name,
        master_view, master_owner, master, master_link,
	can_use_log, last_refresh, error, type, "NEXT", start_with, query)
  AS SELECT
       EXPAND (owner,            30),
       EXPAND (tablename,        30),
       EXPAND (NULL,             30),
       EXPAND (master_owner,     30),
       EXPAND (master_tablename, 30),
       EXPAND (NULL,             30),
       EXPAND (NULL,             30),
       fast_refreshable,
       TIMESTAMP (NULL, NULL),
       FIXED (NULL),
       'FORCE   ',
       EXPAND (NULL, 254),
       TIMESTAMP (NULL, NULL),
       definition
     FROM sysdd.db_snapshots
*
GRANT ALL ON dba_snapshots TO PUBLIC
*

CREATE VIEW dba_snapshot_logs
      (log_owner, master, log_table, log_trigger, current_snapshots)
  AS SELECT
       EXPAND (owner,                 30),
       EXPAND (tablename,             30),
       EXPAND ('MLOG$_' || tablename, 30),
       EXPAND (NULL, 30),
       TIMESTAMP (NULL, NULL)
     FROM sysdd.tables
     WHERE snapshot_log = 'YES'
*
GRANT ALL ON dba_snapshot_logs TO PUBLIC
*

CREATE VIEW dba_source
      (owner, name, type, line, text)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  30),
       EXPAND (' ',  11),
       1,
       EXPAND (' ',  200)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_source TO PUBLIC
*

CREATE VIEW dba_stmt_audit_opts
      (user_name, audit_option, success, failure)
  AS SELECT
       EXPAND (USER, 30),
       '-/-', '-/-', '-/-'
    FROM dual
      WHERE 0 = 1
*
GRANT ALL ON dba_stmt_audit_opts TO PUBLIC
*

CREATE VIEW dba_synonyms
      (owner, synonym_name, table_owner, table_name, db_link)
    AS SELECT
        EXPAND (synonymowner, 30),
        EXPAND (synonymname,  30),
        EXPAND (owner,        30),
        EXPAND (tablename,    30),
        EXPAND (NULL,         30)
    FROM sysdd.db_synonyms
*
GRANT ALL ON dba_synonyms TO PUBLIC
*

CREATE VIEW dba_sys_privs
      (grantee, privilege, admin_option)
  AS SELECT
       EXPAND (USER, 30),
       EXPAND (' ',  40),
       'NO '
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_sys_privs TO PUBLIC
*

CREATE VIEW dba_tables
      (owner, table_name, tablespace_name, cluster_name,
       pct_free, pct_used, ini_trans, max_trans,
       initial_extent, next_extent, min_extents, max_extents, pct_increase,
       backed_up, num_rows, blocks, empty_blocks, avg_space, chain_cnt,
       avg_row_len)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
	'SYSTEM                        ',
        NULL,
        FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	'N',
        FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL),
	FIXED (NULL)
      FROM sysdd.db_tables
        WHERE type = 'TABLE'
*
GRANT ALL ON dba_tables TO PUBLIC
*

CREATE VIEW dba_tablespaces
      (tablespace_name, initial_extent, next_extent, min_extents, max_extents,
       pct_increase, status)
     AS SELECT
       'SYSTEM                        ',
       999999999999999999,
       0,
       1,
       1,
       0,
       'UNDEFINED'
     FROM dual
       WHERE 0=1
*
GRANT ALL ON dba_tablespaces TO PUBLIC
*

CREATE VIEW dba_tab_columns
            (owner, table_name, column_name,
            data_type, data_length, data_precision, data_scale,
            nullable, column_id, default_length, data_default,
	    num_distinct, low_value, high_value, density)
    AS SELECT
        EXPAND (owner,      30),
        EXPAND (tablename,  30),
        EXPAND (columnname, 30),
        DECODE (datatype, 'CHAR',    DECODE (code, 'BYTE', 'RAW', 'VARCHAR2'),
                          'FLOAT',   DECODE (len, NULL, 'NUMBER', 'FLOAT'),
                          'VARCHAR', 'VARCHAR2',
                                     SUBSTR (datatype, 1, 9)),
        DECODE (datatype, 'NUMBER',  22,
                          'FLOAT',   22,
                          'DATE',    7,
                          'LONG',    28,
                                     len),
        DECODE (datatype, 'NUMBER', len, 'FLOAT', len),
        DECODE (datatype, 'NUMBER', dec),
        DECODE (mod || DECODE ("DEFAULT", NULL, '-NOD'), 'OPT-NOD', 'Y', 'N'),
        columnno,
        DECODE (datatype, 'NUMBER', LENGTH (LTRIM ("DEFAULT")),
                          'FLOAT',  LENGTH (LTRIM ("DEFAULT")),
                                    LENGTH ("DEFAULT"))
        +
        DECODE (mod, 'OPT', 0, 1),
        "DEFAULT",
        distinctvalues,
        HEX (NULL),
	HEX (NULL),
	FIXED (NULL)
      FROM sysdd.db_columns
*
GRANT ALL ON dba_tab_columns TO PUBLIC
*

CREATE VIEW dba_tab_comments
      (owner, table_name, table_type, comments)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        EXPAND (type,      11),
        comment_c
    FROM sysdd.db_tables
*
GRANT ALL ON dba_tab_comments TO PUBLIC
*

CREATE VIEW dba_tab_privs
      (grantee, owner, table_name, grantor, privilege, grantable)
    AS SELECT
        EXPAND (grantee,   30),
        EXPAND (owner,     30),
        EXPAND (name1,     30),
        EXPAND (grantor,   30),
        RTRIM  (privileges, '+'),
        DECODE (INDEX (privileges, '+'), 0, 'NO', 'YES')
    FROM sysdd.db_new_privileges
       WHERE name2 IS NULL
*
GRANT ALL ON dba_tab_privs TO PUBLIC
*

CREATE VIEW dba_triggers
      (owner, trigger_name, trigger_type, triggering_event,
       table_owner, table_name, referencing_names, when_clause,
       status, description, trigger_body)
  AS SELECT
       EXPAND (owner,       30),
       EXPAND (triggername, 30),
       'AFTER EACH ROW  ',
       DECODE (SUBSTR (insert, 1, 1) ||
               SUBSTR (update, 1, 1) ||
               SUBSTR (delete, 1, 1),
               'YNN', 'INSERT',
	       'NYN', 'UPDATE',
	       'NNY', 'DELETE',
	       'YYN', 'INSERT OR UPDATE',
	       'YNY', 'INSERT OR DELETE',
	       'NYY', 'UPDATE OR DELETE',
	       'YYY', 'INSERT OR UPDATE OR DELETE',
                      'ERROR'),
       EXPAND (owner,     30),
       EXPAND (tablename, 30),
       EXPAND (NULL,      87),
       EXPAND (NULL,      200),
       'ENABLED ',
       definition_c,
       NULL
     FROM sysdd.db_triggers
*
GRANT ALL ON dba_triggers TO PUBLIC
*

CREATE VIEW dba_trigger_cols
      (trigger_owner, trigger_name,
       table_owner, table_name, column_name, column_list, column_usage)
  AS SELECT
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       EXPAND (' ', 30),
       'NO ',
       EXPAND (' ', 17)
     FROM dual
     WHERE 0 = 1
*
GRANT ALL ON dba_trigger_cols TO PUBLIC
*

CREATE VIEW dba_ts_quotas
      (tablespace_name, username, bytes, max_bytes, blocks, max_blocks)
   AS SELECT 'SYSTEM                        ',
             EXPAND (' ', 30),
             0,
             999999999999999999,
             0,
             999999999999999999
        FROM dual
        WHERE 0 = 1
*
GRANT ALL ON dba_ts_quotas TO PUBLIC
*

CREATE VIEW dba_users
      (username, user_id, password,
       default_tablespace, temporary_tablespace, created, profile)
    AS SELECT
        EXPAND (username, 30),
        user_id,
        EXPAND (NULL,     30),
        'SYSTEM                        ',
	'SYSTEM                        ',
        TIMESTAMP ("DATE", "TIME"),
	EXPAND (NULL, 30)
    FROM sysdd.db_users
*
GRANT ALL ON dba_users TO PUBLIC
*

CREATE VIEW dba_views
      (owner, view_name, text_length, text)
    AS SELECT
        EXPAND (owner,     30),
        EXPAND (tablename, 30),
        len,
        definition
    FROM sysdd.db_views
*
GRANT ALL ON dba_views TO PUBLIC
*

CREATE VIEW dba_waiters
      (waiting_session, holding_session, type, mode_held, mode_requested,
       lock_id1, lock_id2)
  AS SELECT
       0,
       0,
       'LS',
       'EXCLUSIVE',
       'EXCLUSIVE',
       0,
       0
     FROM dual
*
GRANT ALL ON dba_waiters TO PUBLIC
*

END INIT SERVERDB
*
SQLMODE ADABAS
*
USE USER &u
*
