MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/ctx/admin/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/ctx/admin/ctxsys.sql

Rem
Rem $Header: ctx_src_2/src/dr/admin/ctxsys.sql /main/35 2017/02/06 21:05:03 stanaya Exp $
Rem
Rem ctxsys.sql
Rem
Rem Copyright (c) 2002, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      ctxsys.sql <password> <tablespc> <temptblspc> <LOCK|NOLOCK>
Rem
Rem    DESCRIPTION
Rem      schema creation and granting privileges (schema name CTXSYS,
Rem      grant EXECUTE on dbms_registry, alter user lock account
Rem      expire password
Rem
Rem    NOTES
Rem
Rem
Rem    BEGIN SQL_FILE_METADATA 
Rem      SQL_SOURCE_FILE: ctx_src_2/src/dr/admin/ctxsys.sql 
Rem      SQL_SHIPPED_FILE: ctx/admin/ctxsys.sql
Rem      SQL_PHASE: CTXSYS
Rem      SQL_STARTUP_MODE: NORMAL 
Rem      SQL_IGNORABLE_ERRORS: NONE 
Rem      SQL_CALLING_FILE: ctx/admin/catctx.sql
Rem    END SQL_FILE_METADATA
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    boxia       01/17/17 - Proj 68638: rm dbms_scheduler privilege to ctxapp
Rem    snetrava    01/09/17 - Moved the file access trigger to ctxtab.sql
Rem    snetrava    01/04/17 - Bug 25266492,25266515 FILE_ACCESS_ROLE security
Rem    boxia       11/19/16 - Bug 25172618: grant create job, manage
Rem                           scheduler to ctxapp
Rem    rodfuent    11/03/16 - Bug 25028151: composite partition for context_v2
Rem    nspancha    06/30/16 - Bug 23501267: Security Bug
Rem    boxia       01/15/16 - Bug 22226636: replace user$ with _BASE_USER
Rem    rkadwe      09/23/15 - Bug 21701234
Rem    rkadwe      09/23/15 - Bug 21701234
Rem    surman      01/26/15 - 20411134: Add SQL metadata tags
Rem    yinlu       05/09/14 - grant select on sys.opqtype
Rem    boxia       12/12/13 - Bug 16989137: grant select on dba_procedures to
Rem                           CTXSYS
Rem    surman      03/15/13 - 16473661: Common start and end scripts
Rem    dalpern     02/15/12 - proj 32719: INHERIT PRIVILEGES privilege
Rem    rpalakod    11/10/11 - add grants on dba_indexes, dba_triggers
Rem    bhristov    10/30/11 - grant set container to ctxsys
Rem    hsarkar     08/12/11 - Bug 12867992: grant inherit any privileges to
Rem                           CTXSYS
Rem    jmadduku    02/23/11 - Proj32507: Grant Unlimited Tablespace with
Rem                           RESOURCE role
Rem    rpalakod    02/08/10 - Bug 9310235
Rem    rpalakod    08/03/09 - autooptimize
Rem    oshiowat    05/13/05 - feature usage tracking 
Rem    yucheng     11/09/04 - grant ctxsys privs on MV table/views 
Rem    gkaminag    08/02/04 - deprecation of connect 
Rem    ekwan       10/03/03 - Bug 3161706: cannot get column type for nested 
Rem    surman      09/04/03 - 3101316: Update duc$ for drop user cascade 
Rem    gkaminag    08/19/03 - grant ctxsys permissions on ctxapp role 
Rem    ekwan       07/01/03 - Bug 2999760: grant dba_tab_cols
Rem    gkaminag    01/07/03 - dba_indextypes
Rem    gkaminag    12/03/02 - make ctxsys a normal user
Rem    ehuang      09/09/02 - grant more sys tables
Rem    gkaminag    08/22/02 - 
Rem    ehuang      07/08/02 - migrate from dr* scripts
Rem    ehuang      06/17/02 - ehuang_component_upgrade
Rem    ehuang      06/11/02 - Created
Rem

@@?/rdbms/admin/sqlsessstart.sql

define pass   = &1
define tbs    = &2
define ttbs   = &3
define dolock = &4

prompt ...creating user CTXSYS
create user ctxsys
identified by &pass default tablespace &tbs temporary tablespace &ttbs;

grant create session, alter session, create view, create synonym, resource , unlimited tablespace, set container, inherit any privileges to CTXSYS;
grant inherit privileges on user sys to ctxsys;
grant execute on DBMS_PRIV_CAPTURE to ctxsys;

--Bug fix 12867992
declare
  already_revoked exception;
  pragma exception_init(already_revoked,-01927);
begin
  execute immediate 'revoke inherit privileges on user CTXSYS from PUBLIC';
exception
  when already_revoked then
    null;
end;
/

Rem If XDB is already installed, grant CTXSYS inherit privileges on it.
declare
  v varchar2(100);
begin
  select u.name into v from "_BASE_USER" u, registry$ r where u.user# = r.schema# and
        u.name = 'XDB';
  execute immediate 'grant inherit privileges on user xdb to ctxsys';
exception when NO_DATA_FOUND then
    null;
end;
/

REM
REM Needed for ctx_servers
REM

grant select on sys.v_$session to ctxsys with grant option;

grant create public synonym to ctxsys;
grant drop public synonym to ctxsys;

grant select on SYS.GV_$DB_OBJECT_CACHE to ctxsys;
grant select on SYS.ARGUMENT$ to ctxsys with grant option;
grant select on SYS.DBA_COLL_TYPES to ctxsys;
grant select on SYS.DBA_CONSTRAINTS to ctxsys;
grant select on SYS.DBA_CONS_COLUMNS to ctxsys with grant option;
grant select on SYS.DBA_DB_LINKS to ctxsys with grant option;
grant select on SYS.DBA_INDEXTYPES to ctxsys with grant option;
grant select on SYS.DBA_JOBS to ctxsys;
grant select on SYS.DBA_JOBS_RUNNING to ctxsys;
grant select on SYS.DBA_OBJECTS to ctxsys with grant option;
grant select on SYS.DBA_OBJECTS to ctxsys;
grant select on SYS.DBA_PROCEDURES to ctxsys;
grant select on SYS.DBA_ROLES to ctxsys with grant option;
grant select on SYS.DBA_ROLE_PRIVS to ctxsys with grant option;
grant select on SYS.DBA_SYNONYMS to ctxsys with grant option;
grant select on SYS.DBA_SYS_PRIVS to ctxsys;
grant select on SYS.DBA_TABLES to ctxsys;
grant select on SYS.DBA_TAB_COLUMNS to ctxsys;
grant select on SYS.DBA_TAB_COLS to ctxsys;
grant select on SYS.DBA_TAB_PARTITIONS to ctxsys;
grant select on SYS.DBA_TAB_SUBPARTITIONS to ctxsys;
grant select on SYS.DBA_TAB_PRIVS to ctxsys with grant option;
grant select on SYS.DBA_TYPE_ATTRS to ctxsys with grant option;
grant select on SYS.DBA_INDEXES to ctxsys;
grant select on SYS.DBA_TRIGGERS to ctxsys;
grant select on SYS.DBA_PART_KEY_COLUMNS to ctxsys;
grant select on SYS.DBA_SEGMENTS to ctxsys;
grant select on SYS.DBA_USERS to ctxsys;
grant select on SYS.GV_$PARAMETER to ctxsys;
grant select on SYS.COL$ to ctxsys with grant option;
grant select on SYS.COLTYPE$ to ctxsys;
grant select on SYS.IND$ to ctxsys with grant option;
grant select on SYS.INDPART$ to ctxsys with grant option;
grant select on SYS.LOB$ to ctxsys with grant option;
grant select on SYS.LOBFRAG$ to ctxsys with grant option;
grant select on SYS.OBJ$ to ctxsys with grant option;
grant select on SYS.PARTOBJ$ to ctxsys with grant option;
grant select on SYS.SYN$ to ctxsys with grant option;
grant select on SYS.SYSAUTH$ to ctxsys with grant option;
grant select on SYS.TAB$ to ctxsys with grant option;
grant select on SYS.TABPART$ to ctxsys with grant option;
grant select on SYS.TS$ to ctxsys with grant option;
grant select on SYS."_BASE_USER" to ctxsys with grant option;
grant select on SYS."_BASE_USER" to ctxsys with grant option;
grant select on SYS.VIEW$ to ctxsys with grant option;
grant select on SYS.V_$PARAMETER to ctxsys with grant option;
grant select on SYS.V_$RESOURCE to ctxsys with grant option;
grant select on dba_types to ctxsys with grant option;
grant select on SYS.V_$THREAD to ctxsys with grant option;
grant select on SYS.CDEF$ to ctxsys with grant option;
grant select on SYS.CON$ to ctxsys with grant option;
grant select on SYS.CCOL$ to ctxsys with grant option;
grant select on SYS.ICOL$ to ctxsys with grant option;
grant select on SYS.snap$ to ctxsys with grant option;
grant select on SYS.v_$db_pipes to ctxsys;
grant select on SYS.OPQTYPE$ to ctxsys;

grant execute on dbms_pipe to ctxsys;
grant execute on dbms_lock to ctxsys;
grant execute on dbms_registry to ctxsys;
grant create job to ctxsys;
grant manage scheduler to ctxsys;

promp ...creating role CTXAPP
create role CTXAPP;
grant ctxapp to ctxsys with admin option;

begin
  if ('&dolock' = 'LOCK') then
    execute immediate
      'alter user ctxsys password expire account lock';
  end if;
end;
/

REM Support DROP USER CASCADE
DELETE FROM sys.duc$
  WHERE owner = 'CTXSYS'
    AND pack = 'CTX_ADM'
    AND proc = 'DROP_USER_OBJECTS'
    AND operation# = 1;

INSERT INTO sys.duc$ (owner, pack, proc, operation#, seq, com)
  VALUES ('CTXSYS', 'CTX_ADM', 'DROP_USER_OBJECTS', 1, 1,
          'Drops any Text objects for this user');

COMMIT;

@?/rdbms/admin/sqlsessend.sql

OHA YOOOO