SYSTEM_PRIVILEGE_MAP

What is the 'PROPERTY' field in SYSTEM_PRIVILEGE_MAP for?
Thx.
Aliq

SR = Service Request.
You can raise a service request to the Oracle Support on http://metalink.oracle.com (a valid Support Identifier is required, you have to pay for support) when you have a problem against the Oracle database product.
Nicolas.

Similar Messages

  • Output of system_privilege_map for version 10g needed

    Hello everyone.
    I need the output of system_privilege_map for Oracle DB version 10g because i've no access to a 10g db at the moment but i need the complete list of the system privileges with 173 entries.
    Hope someone of you will be such nice and post it here for me :-)
    Thanks in advance.
    Jim

    Hi,
    In 10.2.0.3 i get 166 entries - confirmed with what exists in sql.bsq
    grep SYSTEM_PRIVILEGE_MAP sql.bsq |grep -i insert |grep -v rem |wc -l
    =166
    SQL> /
    -3 ALTER SYSTEM 0
    -4 AUDIT SYSTEM 0
    -5 CREATE SESSION 0
    -6 ALTER SESSION 0
    -7 RESTRICTED SESSION 0
    -10 CREATE TABLESPACE 0
    -11 ALTER TABLESPACE 0
    -12 MANAGE TABLESPACE 0
    -13 DROP TABLESPACE 0
    -15 UNLIMITED TABLESPACE 0
    -20 CREATE USER 0
    -21 BECOME USER 0
    -22 ALTER USER 0
    -23 DROP USER 0
    -30 CREATE ROLLBACK SEGMENT 0
    -31 ALTER ROLLBACK SEGMENT 0
    -32 DROP ROLLBACK SEGMENT 0
    -40 CREATE TABLE 0
    -41 CREATE ANY TABLE 0
    -42 ALTER ANY TABLE 0
    -43 BACKUP ANY TABLE 0
    -44 DROP ANY TABLE 0
    -45 LOCK ANY TABLE 0
    -46 COMMENT ANY TABLE 0
    -47 SELECT ANY TABLE 0
    -48 INSERT ANY TABLE 0
    -49 UPDATE ANY TABLE 0
    -50 DELETE ANY TABLE 0
    -60 CREATE CLUSTER 0
    -61 CREATE ANY CLUSTER 0
    -62 ALTER ANY CLUSTER 0
    -63 DROP ANY CLUSTER 0
    -71 CREATE ANY INDEX 0
    -72 ALTER ANY INDEX 0
    -73 DROP ANY INDEX 0
    -80 CREATE SYNONYM 0
    -81 CREATE ANY SYNONYM 0
    -82 DROP ANY SYNONYM 0
    -83 SYSDBA 0
    -84 SYSOPER 0
    -85 CREATE PUBLIC SYNONYM 0
    -86 DROP PUBLIC SYNONYM 0
    -90 CREATE VIEW 0
    -91 CREATE ANY VIEW 0
    -92 DROP ANY VIEW 0
    -105 CREATE SEQUENCE 0
    -106 CREATE ANY SEQUENCE 0
    -107 ALTER ANY SEQUENCE 0
    -108 DROP ANY SEQUENCE 0
    -109 SELECT ANY SEQUENCE 0
    -115 CREATE DATABASE LINK 0
    -120 CREATE PUBLIC DATABASE LINK 0
    -121 DROP PUBLIC DATABASE LINK 0
    -125 CREATE ROLE 0
    -126 DROP ANY ROLE 0
    -127 GRANT ANY ROLE 0
    -128 ALTER ANY ROLE 0
    -130 AUDIT ANY 0
    -135 ALTER DATABASE 0
    -138 FORCE TRANSACTION 0
    -139 FORCE ANY TRANSACTION 0
    -140 CREATE PROCEDURE 0
    -141 CREATE ANY PROCEDURE 0
    -142 ALTER ANY PROCEDURE 0
    -143 DROP ANY PROCEDURE 0
    -144 EXECUTE ANY PROCEDURE 0
    -151 CREATE TRIGGER 0
    -152 CREATE ANY TRIGGER 0
    -153 ALTER ANY TRIGGER 0
    -154 DROP ANY TRIGGER 0
    -160 CREATE PROFILE 0
    -161 ALTER PROFILE 0
    -162 DROP PROFILE 0
    -163 ALTER RESOURCE COST 0
    -165 ANALYZE ANY 0
    -167 GRANT ANY PRIVILEGE 0
    -172 CREATE MATERIALIZED VIEW 0
    -173 CREATE ANY MATERIALIZED VIEW 0
    -174 ALTER ANY MATERIALIZED VIEW 0
    -175 DROP ANY MATERIALIZED VIEW 0
    -177 CREATE ANY DIRECTORY 0
    -178 DROP ANY DIRECTORY 0
    -180 CREATE TYPE 0
    -181 CREATE ANY TYPE 0
    -182 ALTER ANY TYPE 0
    -183 DROP ANY TYPE 0
    -184 EXECUTE ANY TYPE 0
    -186 UNDER ANY TYPE 0
    -188 CREATE LIBRARY 0
    -189 CREATE ANY LIBRARY 0
    -190 ALTER ANY LIBRARY 0
    -191 DROP ANY LIBRARY 0
    -192 EXECUTE ANY LIBRARY 0
    -200 CREATE OPERATOR 0
    -201 CREATE ANY OPERATOR 0
    -202 ALTER ANY OPERATOR 0
    -203 DROP ANY OPERATOR 0
    -204 EXECUTE ANY OPERATOR 0
    -205 CREATE INDEXTYPE 0
    -206 CREATE ANY INDEXTYPE 0
    -207 ALTER ANY INDEXTYPE 0
    -208 DROP ANY INDEXTYPE 0
    -209 UNDER ANY VIEW 0
    -210 QUERY REWRITE 0
    -211 GLOBAL QUERY REWRITE 0
    -212 EXECUTE ANY INDEXTYPE 0
    -213 UNDER ANY TABLE 0
    -214 CREATE DIMENSION 0
    -215 CREATE ANY DIMENSION 0
    -216 ALTER ANY DIMENSION 0
    -217 DROP ANY DIMENSION 0
    -218 MANAGE ANY QUEUE 1
    -219 ENQUEUE ANY QUEUE 1
    -220 DEQUEUE ANY QUEUE 1
    -222 CREATE ANY CONTEXT 0
    -223 DROP ANY CONTEXT 0
    -224 CREATE ANY OUTLINE 0
    -225 ALTER ANY OUTLINE 0
    -226 DROP ANY OUTLINE 0
    -227 ADMINISTER RESOURCE MANAGER 1
    -228 ADMINISTER DATABASE TRIGGER 0
    -233 MERGE ANY VIEW 0
    -234 ON COMMIT REFRESH 0
    -235 EXEMPT ACCESS POLICY 0
    -236 RESUMABLE 0
    -237 SELECT ANY DICTIONARY 0
    -238 DEBUG CONNECT SESSION 0
    -241 DEBUG ANY PROCEDURE 0
    -243 FLASHBACK ANY TABLE 0
    -244 GRANT ANY OBJECT PRIVILEGE 0
    -245 CREATE EVALUATION CONTEXT 1
    -246 CREATE ANY EVALUATION CONTEXT 1
    -247 ALTER ANY EVALUATION CONTEXT 1
    -248 DROP ANY EVALUATION CONTEXT 1
    -249 EXECUTE ANY EVALUATION CONTEXT 1
    -250 CREATE RULE SET 1
    -251 CREATE ANY RULE SET 1
    -252 ALTER ANY RULE SET 1
    -253 DROP ANY RULE SET 1
    -254 EXECUTE ANY RULE SET 1
    -255 EXPORT FULL DATABASE 0
    -256 IMPORT FULL DATABASE 0
    -257 CREATE RULE 1
    -258 CREATE ANY RULE 1
    -259 ALTER ANY RULE 1
    -260 DROP ANY RULE 1
    -261 EXECUTE ANY RULE 1
    -262 ANALYZE ANY DICTIONARY 0
    -263 ADVISOR 0
    -264 CREATE JOB 0
    -265 CREATE ANY JOB 0
    -266 EXECUTE ANY PROGRAM 0
    -267 EXECUTE ANY CLASS 0
    -268 MANAGE SCHEDULER 0
    -269 SELECT ANY TRANSACTION 0
    -270 DROP ANY SQL PROFILE 0
    -271 ALTER ANY SQL PROFILE 0
    -272 ADMINISTER SQL TUNING SET 0
    -273 ADMINISTER ANY SQL TUNING SET 0
    -274 CREATE ANY SQL PROFILE 0
    -275 EXEMPT IDENTITY POLICY 0
    -276 MANAGE FILE GROUP 1
    -277 MANAGE ANY FILE GROUP 1
    -278 READ ANY FILE GROUP 1
    -279 CHANGE NOTIFICATION 0
    -280 CREATE EXTERNAL JOB 0
    166 rows selected.
    In theory 10.2.0.4/10.2.0.5 could have altered this and 10.2.0.1 base version could be different from 10.2.0.3......
    Cheers,
    Harry

  • Why does the DICTIONARY don't show the system_privilege_map table?

    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    5 rows selected.
    SQL> desc system_privilege_map
    Name                                      Null?    Type
    PRIVILEGE                                 NOT NULL NUMBER
    NAME                                      NOT NULL VARCHAR2(40)
    PROPERTY                                  NOT NULL NUMBER
    SQL> select count(*) from system_privilege_map;
      COUNT(*)
           166
    1 row selected.
    SQL> select * from dict where table_name = upper('system_privilege_map');
    no rows selected
    SQL>Amiel.

    DICT is a synonym for DICTIONARY view.
    Let us take a look to the DICTIONARY view definition :
    SQL> select text from dba_views where view_name = 'DICTIONARY'
    SQL>/
    TEXT
    select o.name, c.comment$
    from sys.obj$ o, sys.com$ c
    where o.obj# = c.obj#(+)
      and c.col# is null
      and o.owner# = 0
      and o.type# = 4
      and (o.name like 'USER%'
           or o.name like 'ALL%'
           or (o.name like 'DBA%'
               and exists
                       (select null
                        from sys.v$enabledprivs
                        where priv_number = -47 /* SELECT ANY TABLE */)
    union all
    select o.name, c.comment$
    from sys.obj$ o, sys.com$ c
    where o.obj# = c.obj#(+)
      and o.owner# = 0
      and o.name 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','NLS_SESSION_PARAMETERS','NLS_INSTANCE_PARAMETERS',
            'NLS_DATABASE_PARAMETERS', 'DATABASE_COMPATIBLE_LEVEL',
            'DBMS_ALERT_INFO', 'DBMS_LOCK_ALLOCATED')
      and c.col# is null
    union all
    select so.name, 'Synonym for ' || sy.name
    from sys.obj$ ro, sys.syn$ sy, sys.obj$ so
    where so.type# = 5
      and ro.linkname is null
      and so.owner# = 1
      and so.obj# = sy.obj#
      and so.name <> sy.name
      and sy.owner = 'SYS'
      and sy.name = ro.name
      and ro.owner# = 0
      and ro.type# = 4
      and (ro.owner# = userenv('SCHEMAID')
           or ro.obj# in
               (select oa.obj#
                from sys.objauth$ oa
                where grantee# in (select kzsrorol from x$kzsro))
           or exists (select null from v$enabledprivs
                      where priv_number in (-45 /* LOCK ANY TABLE */,
                                            -47 /* SELECT ANY TABLE */,
                                            -48 /* INSERT ANY TABLE */,
                                            -49 /* UPDATE ANY TABLE */,
                                            -50 /* DELETE ANY TABLE */)
                      ))Which means listed only some specific objects :
    1. view (o.type# = 4) started by USER%, DBA%, ALL% owned by SYS (o.owner# = 0).
    2. hard coded objects owned by SYS (o.owner# = 0).
    3. Objects created as PUBLIC (so.owner# = 1) synonyms (so.type# = 5) which have a name different than synonym and point to a view (ro.type# = 4) owned by SYS (ro.owner# = 0)
    I have to say that I rarely use DICT(IONARY) view, for my mind it's useless, DBA_OBJECTS is more usefull.
    Lastly, why created this thread in Documentation forum ?
    Nicolas.

  • How to  insert  300 data from associative array to backend table in PL/SQL

    HI ALL,
    I'm posting my code here:
    Creating back end table:
    Create table orlando
    ( id number(20),
    calltype number(12),
         gateway_name varchar2(25),
         accounting_id varchar2(18),
         start_time_system_ticks number(11),
         node_time_zone      varchar2(25),
         start_date varchar2(10),     
         start_time varchar2(10),
         softswitch_response number(11),
         alerting number(11)     
    Creating package:
    CREATE OR REPLACE PACKAGE r IS
    type apollo_rec is record(
    id number(20),
    calltype number(12),
         gateway_name varchar2(25),
         accounting_id varchar2(18),
         start_time_system_ticks number(11),
         node_time_zone      varchar2(25),
         start_date varchar2(10),     
         start_time varchar2(10),
         softswitch_response number(11),
         alerting number(11)
    TYPE bin_array IS TABLE OF apollo_rec INDEX BY BINARY_INTEGER;
    PROCEDURE rr (state_array bin_array);
    END ;
    SET SERVEROUT ON
    CREATE OR REPLACE PACKAGE BODY r IS
    PROCEDURE rr (state_array bin_array) IS
    BEGIN
    FOR i IN 1 .. state_array.COUNT LOOP
    INSERT INTO orlando(id,calltype,gateway_name,accounting_id,start_time_system_ticks)VALUES(state_array(i).id,state_array(i).calltype,state_array(i).gateway_name,
    state_array(i).accounting_id,state_array(i).start_time_system_ticks);
    COMMIT;
    END LOOP;
    END ;
    END ;
    I've run this code in i*SQL PLUS.But when I run this code for 5 entries there is no error but when I modify the insert statement for 300 entries(300 identifiers in the insert statement)
    it gives me error:
    Warning: Package Body created with compilation errors.
    Errors for PACKAGE BODY R:
    LINE/COL      ERROR
    7/2      PL/SQL: SQL Statement ignored
    7/14      PL/SQL: ORA-00913: too many values
    Is there any feature in PL/SQL to decrease the entries in insert statement and make the insert statement along with the program small and increase the program performance.
    Edited by: 983040 on Jan 20, 2013 11:11 PM

    Basic example (ran on 11.2.0.3):
    SQL> create table testtab( id number, day date, val varchar2(30) );
    Table created.
    SQL>
    SQL> create or replace package TestTabLib as
      2 
      3          type TTestTab is table of testtab%rowtype;
      4 
      5          procedure InsertRows( rowArray TTestTab );
      6 
      7  end;
      8  /
    Package created.
    SQL>
    SQL> create or replace package body TestTabLib as
      2 
      3          procedure InsertRows( rowArray TTestTab ) is
      4          begin
      5                  forall i in 1..rowArray.Count
      6                          insert into testtab values rowArray(i);
      7          end;
      8 
      9  end;
    10  /
    Package body created.
    SQL>
    SQL> declare
      2          rowArray        TestTabLib.TTestTab;
      3  begin
      4          --// populating the array - using a bulk fetch as
      5          --// an example
      6          select
      7                  object_id, created, object_name
      8                          bulk collect into
      9                  rowArray
    10          from    all_objects
    11          where   rownum < 11;
    12 
    13          --// bulk insert array
    14          TestTabLib.InsertRows( rowArray );
    15  end;
    16  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from testtab;
            ID DAY                 VAL
           100 2011/12/05 09:16:03 ORA$BASE
           116 2011/12/05 09:16:04 DUAL
           117 2011/12/05 09:16:04 DUAL
           280 2011/12/05 09:19:09 MAP_OBJECT
           365 2011/12/05 09:19:10 SYSTEM_PRIVILEGE_MAP
           367 2011/12/05 09:19:10 SYSTEM_PRIVILEGE_MAP
           368 2011/12/05 09:19:10 TABLE_PRIVILEGE_MAP
           370 2011/12/05 09:19:11 TABLE_PRIVILEGE_MAP
           371 2011/12/05 09:19:11 STMT_AUDIT_OPTION_MAP
           373 2011/12/05 09:19:11 STMT_AUDIT_OPTION_MAP
    10 rows selected.
    SQL>
    SQL> declare
      2          rowArray        TestTabLib.TTestTab;
      3  begin
      4          --// populating the array - using a custom build
      5          --// loop example such as a Java front-end will
      6          --// use reading data from user input form
      7          rowArray := new TestTabLib.TTestTab();
      8          rowArray.Extend(2);     --// user entered 2 values
      9          for i in 1..rowArray.Count loop
    10                  rowArray(i).id := i;
    11                  rowArray(i).day := trunc(sysdate);
    12                  rowArray(i).val := 'value '||to_char(i,'000');
    13          end loop;
    14 
    15          --// bulk insert array
    16          TestTabLib.InsertRows( rowArray );
    17  end;
    18  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from testtab where val like 'value%';
            ID DAY                 VAL
             1 2013/01/21 00:00:00 value  001
             2 2013/01/21 00:00:00 value  002
    SQL>

  • Creating a function to return a table of records

    Okay, I thought I knew how to do this but apparently not. I have a very complex query that connects multiple tables. I want to put the results of that query into a "table" (non-persistent) that can be passed to another procedure. So, I created an object/record that defines a single row in this table:
    create or replace TYPE SHP_RECORD is OBJECT
    (FIELD01 NUMBER(10),
    FIELD02 NUMBER(10),
    FIELD03 NUMBER(10),
    FIELD04 NUMBER(10),
    FIELD05 NUMBER(10),
    FIELD06 VARCHAR2(200),
    FILED07 NUMBER(10),
    FIELD08 VARCHAR2(200),
    FIELD09 NUMBER(10),
    FIELD10 TIMESTAMP(6),
    FIELD11 TIMESTAMP(6),
    FIELD12 TIMESTAMP(6),
    FIELD13 VARCHAR2(5),
    FIELD14 NUMBER(10),
    FIELD15 VARCHAR2(100),
    FIELD16 VARCHAR2(4000),
    FIELD17 VARCHAR2(1),
    FIELD18 VARCHAR2(1));
    Then I create another type that defines a table of SHP_RECORD:
    Create or replace TYPE SHP_TABLE is TABLE of SHP_RECORD;
    Now I have a function that puts the huge query into a text string (because it's got elements that change depending on what day of the week it's being run on so I have to keep it as a dynamic query. Now I want to run this query and put the results into a table. I've changed all the names to protect the innocent in this code snippet:
    create or replace function get_SHP_data(p_cust_id IN NUMBER,
    p_date IN TIMESTAMP) return SHP_TABLE as
    begin
    declare
    shp_data_out SHP_TABLE;
    TYPE shp_cur_type is REF CURSOR;
    shp_cv shp_cur_type;
    TYPE daily_query is VARRAY(7) of VARCHAR2(15);
    query_values DAILY_QUERY;
    day_index NUMBER;
    old_program_id NUMBER;
    chk_rundown NUMBER;
    query_text VARCHAR2(3000);
    row_index NUMBER;
    program_freq_id NUMBER;
    prog_seg_count NUMBER;
    upload_seg_count NUMBER;
    xfer_count NUMBER;
    sched_count NUMBER;
    bill_count NUMBER;
    rcvr_text VARCHAR2(2000);
    xmsn_start TIMESTAMP;
    xmsn_end TIMESTAMP;
    epi_status VARCHAR2(2000);
    begin
    query_values := daily_query('1, 3, 4, 12','1, 2, 5, 12','1, 2, 6, 12','1, 2, 7, 12','1, 2, 8, 12','1, 2, 9, 12','1, 3, 10, 12');
    day_index := to_number(to_char(p_date,'D'));
    query_text := {really ugly query here that includes concatinating a value from query_values as well as defines five bind variables numbered :1 through :5};
    old_program_id := 0;
    open shp_cv for query_text using p_date, p_date, p_date, p_date, p_cust_id;
    fetch shp_cv bulk collect into shp_data_out;
    close shp_cv;
    end;
    end;
    Okay, the function compiles just fine. But when I try to run it I get:
    select * from table(get_shp_data(226, SYSTIMESTAMP))
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got -
    ORA-06512: at "SCHEMA.GET_SHP_DATA", line 69
    The line it's blowing up on is "fetch ship_cv bulk collect into shp_data_out" I've checked and verified that the record/object structure SHP_RECORD matches in both type and order the values that are returned by the query. So...what gives? I've been beating my head against this particular problem for several days now and am no closer to a solution.
    Any and all suggestions or corrections gratefully appreciated.
    Oh, and this is being run in a 10g release 2 environment:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    HELP??!!

    Hi,
    Even though the fetch is seemingly taking the exact same types, Oracle will still need you to cast the resultset into the proper type.
    Here's a short example of one way of doing it:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.5.0
    Connected as FSITJA
    SQL>
    SQL> create table my_table as select owner, table_name from all_tables where rownum <= 5;
    Table created
    SQL> create or replace type SHP_RECORD as object (owner varchar2(30), table_name varchar2(30));
      2  /
    Type created
    SQL> create or replace type SHP_TABLE as table of SHP_RECORD;
      2  /
    Type created
    SQL> create or replace function get_shp_data(p_owner in my_table.owner%type) return shp_table as
      2    shp_data_out shp_table;
      3    cur_shp sys_refcursor;
      4  begin
      5    open cur_shp for
      6      select cast (multiset(select owner, table_name
      7                              from all_tables
      8                             where owner = p_owner
      9                               and rownum <= 5) as shp_table)
    10         from dual;
    11    fetch cur_shp
    12      into shp_data_out;
    13    return shp_data_out;
    14  end;
    15  /
    Function created
    SQL> select * from table(get_shp_data('SYS'));
    OWNER                          TABLE_NAME
    SYS                            TABLE_PRIVILEGE_MAP
    SYS                            SYSTEM_PRIVILEGE_MAP
    SYS                            STMT_AUDIT_OPTION_MAP
    SYS                            P$POK_CFG
    SYS                            DUALYou might want to check on Pipelined table functions and perhaps the function result cache in the docs, as means to improve your performance.
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/tuning.htm#LNPLS01210
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/subprograms.htm#LNPLS00817

  • SQL runs fine on DB11.2.0.1.0 but fails on DB9.2.0.8.0 with errors.

    The below SQL runs fine on DB11.2.0.1.0 but fails on DB9.2.0.8.0 with error:
    WITH users_with_dba_privs AS
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-00904: "from$_subquery$_005"."PARENT": invalid identifier
    SQL
    WITH users_with_dba_privs AS
    (select distinct child user_name
    from (select null parent, 'DBA' child from dual
    union all
    select granted_role parent, grantee child
    from dba_role_privs)
    where child in (select username from dba_users)
    start with parent is null connect by parent = prior child )
    select 'select_any_table',
    substr(SYS_CONNECT_BY_PATH(c, '->'),3,512) path, c
    from (select null p, name c
    from system_privilege_map
    where name = 'SELECT ANY TABLE'
    union all
    select -- users/roles and roles granted
    granted_role p,
    grantee c
    from dba_role_privs
    where granted_role != 'DBA'
    union all
    select -- users/roles with select any table
    privilege p, grantee c
    from dba_sys_privs
    where privilege = 'SELECT ANY TABLE')
    where (c = 'PUBLIC' OR c in (select username from dba_users))
    AND c NOT IN('MDSYS','DMSYS','CTXSYS','WMSYS','ORDSYS','OLAPSYS','DBSNMP')
    and c NOT IN (select user_name from users_with_dba_privs)
    start with p is null connect by p = prior c
    union all
    select 'select_privilege',
    substr(SYS_CONNECT_BY_PATH(c, '->'),3,512) path, c
    from (select null p, view_name c
    from dba_views
    where view_name like 'DBA_%'
    union all
    select -- users/roles and roles granted
    granted_role p,
    grantee c
    from dba_role_privs
    where granted_role != 'DBA'
    union all
    select -- users/roles with select on DBA views
    table_name p, grantee c
    from dba_tab_privs
    where privilege = 'SELECT'
    and table_name like 'DBA_%')
    where (c = 'PUBLIC' OR c in (select username from dba_users))
    AND c NOT IN('MDSYS','DMSYS','CTXSYS','WMSYS','ORDSYS','OLAPSYS','DBSNMP')
    and c NOT IN (select user_name from users_with_dba_privs)
    start with p is null connect by p = prior c
    Thanks in advance.
    ~Hozy

    hoek,
    Why do you think this WITH clause is special?
    I've taken the liberty of formatting the code, and can't see what's wrong. (Maybe I'm just too tired)
    I believe 9i did have subquery factoring.
    with users_with_dba_privs
           as (    select distinct child user_name
                     from (    select null parent, 'DBA' child from dual
                           union all
                           select granted_role parent, grantee child
                             from dba_role_privs)
                    where child in (    select username from dba_users)
               start with parent is null
               connect by parent = prior child)
        select 'select_any_table', substr(sys_connect_by_path(c, '->'), 3, 512) path, c
          from (select null p, name c
                  from system_privilege_map
                 where name = 'SELECT ANY TABLE'
                union all
                select -- users/roles and roles granted
                      granted_role p, grantee c
                  from dba_role_privs
                 where granted_role != 'DBA'
                union all
                select -- users/roles with select any table
                      privilege p, grantee c
                  from dba_sys_privs
                 where privilege = 'SELECT ANY TABLE')
         where (c = 'PUBLIC'
             or c in (    select username from dba_users))
           and c not in
                     ('MDSYS'
                     ,'DMSYS'
                     ,'CTXSYS'
                     ,'WMSYS'
                     ,'ORDSYS'
                     ,'OLAPSYS'
                     ,'DBSNMP')
           and c not in (    select user_name from users_with_dba_privs)
    start with p is null
    connect by p = prior c
    union all
        select 'select_privilege', substr(sys_connect_by_path(c, '->'), 3, 512) path, c
          from (select null p, view_name c
                  from dba_views
                 where view_name like 'DBA_%'
                union all
                select -- users/roles and roles granted
                      granted_role p, grantee c
                  from dba_role_privs
                 where granted_role != 'DBA'
                union all
                select -- users/roles with select on DBA views
                      table_name p, grantee c
                  from dba_tab_privs
                 where privilege = 'SELECT'
                   and table_name like 'DBA_%')
         where (c = 'PUBLIC'
             or c in (    select username from dba_users))
           and c not in
                     ('MDSYS'
                     ,'DMSYS'
                     ,'CTXSYS'
                     ,'WMSYS'
                     ,'ORDSYS'
                     ,'OLAPSYS'
                     ,'DBSNMP')
           and c not in (    select user_name from users_with_dba_privs)
    start with p is null
    connect by p = prior cRegards
    Peter

  • Inconsistent SQL results when using View with UNION-ALL and table function

    Can any of you please execute the below scripts and check the output. In the table type variable, I am adding 4 distinct object ids, where as in the result, I get only the row pertaining to last id in the table type variable. Same row is returned 4 times (4= number of values in the table type).
    This scenario is occurring in our product with a SQL with exactly same pattern. I could simulate the same issue with the sample script I have provided.
    Database version: 11.2.0.3 Enterprise Edition, Single node
    Thank you.
    CREATE TABLE TEMP_T1 AS SELECT * FROM ALL_OBJECTS;
    CREATE TABLE TEMP_T2 AS SELECT * FROM ALL_OBJECTS;
    UPDATE TEMP_T2 SET OBJECT_ID = OBJECT_ID * 37;
    CREATE UNIQUE INDEX TEMP_T1_U1 ON TEMP_T1(OBJECT_ID);
    CREATE UNIQUE INDEX TEMP_T2_U1 ON TEMP_T2(OBJECT_ID);
    CREATE OR REPLACE VIEW TEMP_T1T2_V AS
    SELECT * FROM TEMP_T1 UNION ALL SELECT * FROM TEMP_T2;
    CREATE OR REPLACE TYPE TEMP_OBJ_TYPE AS OBJECT (OBJ_ID NUMBER);
    CREATE OR REPLACE TYPE TEMP_OBJ_TAB_TYPE IS TABLE OF TEMP_OBJ_TYPE;
    SET SERVEROUTPUT ON;
    DECLARE
    TYPE TEMP_T1T2_V_ROW_TAB_TYPE IS TABLE OF TEMP_T1T2_V%ROWTYPE;
    TEMP_T1T2_V_ROW_TAB TEMP_T1T2_V_ROW_TAB_TYPE;
    TEMP_OBJ_TAB TEMP_OBJ_TAB_TYPE := TEMP_OBJ_TAB_TYPE();
    PROCEDURE ADD_TO_TEMP_OBJ_TAB(OBJ_ID IN NUMBER) IS
    BEGIN
    TEMP_OBJ_TAB.EXTEND;
    TEMP_OBJ_TAB(TEMP_OBJ_TAB.LAST) := TEMP_OBJ_TYPE(OBJ_ID);
    END;
    BEGIN
    ADD_TO_TEMP_OBJ_TAB(100);
    ADD_TO_TEMP_OBJ_TAB(116);
    ADD_TO_TEMP_OBJ_TAB(279);
    ADD_TO_TEMP_OBJ_TAB(364);
    DBMS_OUTPUT.PUT_LINE('=====================');
    FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('---------------------');
    SELECT * BULK COLLECT INTO TEMP_T1T2_V_ROW_TAB
    FROM TEMP_T1T2_V VW
    WHERE ((VW.OBJECT_ID) IN (SELECT OBJ_ID
    FROM TABLE(CAST(TEMP_OBJ_TAB AS TEMP_OBJ_TAB_TYPE))));
    FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('---------------------');
    IF TEMP_T1T2_V_ROW_TAB.COUNT > 0 THEN
    FOR I IN TEMP_T1T2_V_ROW_TAB.FIRST..TEMP_T1T2_V_ROW_TAB.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE(TEMP_T1T2_V_ROW_TAB(I).OBJECT_ID||' : '||TEMP_T1T2_V_ROW_TAB(I).OBJECT_NAME);
    END LOOP;
    ELSE
    DBMS_OUTPUT.PUT_LINE('NO ROWS RETURNED!');
    END IF;
    DBMS_OUTPUT.PUT_LINE('---------------------');
    END;
    /

    I can reproduce it:
    SQL*Plus: Release 11.2.0.3.0 Production on Tue Oct 30 14:05:39 2012
    Copyright (c) 1982, 2011, Oracle.  All rights reserved.
    Enter user-name: scott
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select  *
      2    from  v$version
      3  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> CREATE TABLE TEMP_T1 AS SELECT * FROM ALL_OBJECTS;
    Table created.
    SQL>
    SQL> CREATE TABLE TEMP_T2 AS SELECT * FROM ALL_OBJECTS;
    Table created.
    SQL>
    SQL> UPDATE TEMP_T2 SET OBJECT_ID = OBJECT_ID * 37;
    72883 rows updated.
    SQL>
    SQL> CREATE UNIQUE INDEX TEMP_T1_U1 ON TEMP_T1(OBJECT_ID);
    Index created.
    SQL>
    SQL> CREATE UNIQUE INDEX TEMP_T2_U1 ON TEMP_T2(OBJECT_ID);
    Index created.
    SQL>
    SQL> CREATE OR REPLACE VIEW TEMP_T1T2_V AS
      2  SELECT * FROM TEMP_T1 UNION ALL SELECT * FROM TEMP_T2;
    View created.
    SQL>
    SQL> CREATE OR REPLACE TYPE TEMP_OBJ_TYPE AS OBJECT (OBJ_ID NUMBER)
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE TEMP_OBJ_TAB_TYPE IS TABLE OF TEMP_OBJ_TYPE
      2  /
    Type created.
    SQL> SET SERVEROUTPUT ON;
    SQL>
    SQL> DECLARE
      2  TYPE TEMP_T1T2_V_ROW_TAB_TYPE IS TABLE OF TEMP_T1T2_V%ROWTYPE;
      3  TEMP_T1T2_V_ROW_TAB TEMP_T1T2_V_ROW_TAB_TYPE;
      4  TEMP_OBJ_TAB TEMP_OBJ_TAB_TYPE := TEMP_OBJ_TAB_TYPE();
      5  PROCEDURE ADD_TO_TEMP_OBJ_TAB(OBJ_ID IN NUMBER) IS
      6  BEGIN
      7  TEMP_OBJ_TAB.EXTEND;
      8  TEMP_OBJ_TAB(TEMP_OBJ_TAB.LAST) := TEMP_OBJ_TYPE(OBJ_ID);
      9  END;
    10  BEGIN
    11  ADD_TO_TEMP_OBJ_TAB(100);
    12  ADD_TO_TEMP_OBJ_TAB(116);
    13  ADD_TO_TEMP_OBJ_TAB(279);
    14  ADD_TO_TEMP_OBJ_TAB(364);
    15  DBMS_OUTPUT.PUT_LINE('=====================');
    16  FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
    17  LOOP
    18  DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
    19  END LOOP;
    20  DBMS_OUTPUT.PUT_LINE('---------------------');
    21  SELECT * BULK COLLECT INTO TEMP_T1T2_V_ROW_TAB
    22  FROM TEMP_T1T2_V VW
    23  WHERE ((VW.OBJECT_ID) IN (SELECT OBJ_ID
    24  FROM TABLE(CAST(TEMP_OBJ_TAB AS TEMP_OBJ_TAB_TYPE))));
    25  FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
    26  LOOP
    27  DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
    28  END LOOP;
    29  DBMS_OUTPUT.PUT_LINE('---------------------');
    30  IF TEMP_T1T2_V_ROW_TAB.COUNT > 0 THEN
    31  FOR I IN TEMP_T1T2_V_ROW_TAB.FIRST..TEMP_T1T2_V_ROW_TAB.LAST
    32  LOOP
    33  DBMS_OUTPUT.PUT_LINE(TEMP_T1T2_V_ROW_TAB(I).OBJECT_ID||' : '||TEMP_T1T2_V_ROW_TAB(I).OBJECT_NAME);
    34  END LOOP;
    35  ELSE
    36  DBMS_OUTPUT.PUT_LINE('NO ROWS RETURNED!');
    37  END IF;
    38  DBMS_OUTPUT.PUT_LINE('---------------------');
    39  END;
    40  /
    =====================
    OBJ_ID = 100
    OBJ_ID = 116
    OBJ_ID = 279
    OBJ_ID = 364
    OBJ_ID = 100
    OBJ_ID = 116
    OBJ_ID = 279
    OBJ_ID = 364
    364 : I_AUDIT
    364 : I_AUDIT
    364 : I_AUDIT
    364 : I_AUDIT
    PL/SQL procedure successfully completed.
    SQL> column object_name format a30
    SQL> select  object_id,
      2          object_name
      3    from  dba_objects
      4    where object_id in (100,116,279,364)
      5  /
    OBJECT_ID OBJECT_NAME
           100 ORA$BASE
           116 DUAL
           279 MAP_OBJECT
           364 I_AUDIT
    SQL>  Works fine in:
    =====================
    OBJ_ID = 100
    OBJ_ID = 116
    OBJ_ID = 279
    OBJ_ID = 364
    OBJ_ID = 100
    OBJ_ID = 116
    OBJ_ID = 279
    OBJ_ID = 364
    100 : ORA$BASE
    116 : DUAL
    364 : SYSTEM_PRIVILEGE_MAP
    279 : MAP_OBJECT
    PL/SQL procedure successfully completed.
    SQL> select  object_id,
      2          object_name
      3    from  dba_objects
      4    where object_id in (100,116,279,364)
      5  /
    OBJECT_ID OBJECT_NAME
          100 ORA$BASE
          116 DUAL
          364 SYSTEM_PRIVILEGE_MAP
          279 MAP_OBJECT
    SQL> select  *
      2    from  v$version
      3  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>SY.
    Edited by: Solomon Yakobson on Oct 30, 2012 2:14 PM

  • Function returning a query

    Hi guys,
    A query suddenly became very slow & has remained like it while connecting over a database. I assume the reason is because the data is being retrieved from 6 tables across a link (6 different connections to the same database) so I thought a view should be better as I had a similar issue and this seemed to resolve it. However I then thought that perhaps a function returning the results would be faster as it would mean I could include the where clauses & group by clause to be done remotely on the database rather than locally after much more rows were returned...is this assumption correct?
    My query is as follows:
    select     rpad(username,18) user_name, rpad(terminal,18) terminal_id, rpad(userhost,30) host_name, 
               action_name, count(*) actions, sum(sessioncpu) session_cpu
    from
    select     username,
       terminal,
       userhost,
       action_name,
       to_char(timestamp,'DD/MM/YYYY HH24:MI:SS') timestamp,
       logoff_time,
       returncode, session_cpu sessioncpu
    from       dba_audit_session@XXX
    where (logoff_time >= sysdate - :P1_RAD
    AND :P1_RAD IS NOT NULL AND :P1_RAD != -1
    AND :REQUEST != 'But')
    OR (logoff_time >= to_TIMESTAMP(TO_DATE(:P1_FROM, 'DD-MON-YY') || ' ' || :P1_FROM_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND logoff_time < to_TIMESTAMP(TO_DATE(:P1_TO, 'DD-MON-YY') || ' ' || :P1_TO_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND :REQUEST = 'But'
    AND :P1_FROM IS NOT NULL AND :P1_TO IS NOT NULL)
    union
    select username,
            terminal,
       userhost,
       action_name,
       to_char(timestamp,'DD/MM/YYYY HH24:MI:SS') timestamp,
       logoff_time,
       returncode, sessioncpu
    from
    select
           userid            USERNAME ,
           userhost          USERHOST ,
           terminal          TERMINAL ,
           cast (
               (from_tz(ntimestamp#,'00:00') at local) as date) timestamp,
           act.name          ACTION_NAME ,         
           logoff$time logoff_time      /* LOGOFF_TIME   */,
           sessionid         /* SESSIONID */,
           returncode        /* RETURNCODE */,      
           sessioncpu        /* SESSION_CPU */      
    from sys.aud_archive@XXX aud, system_privilege_map@XXX spm, system_privilege_map@XXX spx,
         STMT_AUDIT_OPTION_MAP@XXX aom, audit_actions@XXX act
    where   aud.action#     = act.action    (+)
      and - aud.logoff$dead = spm.privilege (+)
      and   aud.logoff$dead = aom.option#   (+)
      and - aud.priv$used   = spx.privilege (+)
    and act.action between 100 and 102
    where (logoff_time >= sysdate - :P1_rad
    AND :P1_RAD IS NOT NULL AND :P1_RAD != -1
    AND :REQUEST != 'But')
    OR (logoff_time >= to_TIMESTAMP(TO_DATE(:P1_FROM, 'DD-MON-YY') || ' ' || :P1_FROM_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND logoff_time < to_TIMESTAMP(TO_DATE(:P1_TO, 'DD-MON-YY') || ' ' || :P1_TO_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND :REQUEST = 'But'
    AND :P1_FROM IS NOT NULL AND :P1_TO IS NOT NULL)
    group by username,   terminal,   userhost,    action_name
    order by actions desc;So it would take 6 parameters (p1_rad, request, p1_from, p1_to, p1_from_hour, p1_to_hour) and return a table with 8 columns. Would the WHERE & GROUP BY clauses being done remotely rather than on APEX be much better?
    Mike

    In general functions don't help much to increase the performance.
    However sometimes you can programatically choose different select statements depending whether a parameter is filled by the user or not. This allows you as a programmer to provide different and optimized statements depening on the input conditions.
    simplified pseudocode example
    "SELECT"
    select *
    from myTable
    where (column1 = :param1 or :param1 is null); /* problematic to get an index scon on column1 for this OR expression */
    "PL/SQL"
    if :param1 is null then
      select *
      bulk collect into ...
      from myTable; /* Full table scan will be used */
    else
      select *
      bulk collect into ...
      from myTable
      where column1 = :param1; /* index scan on column1 can be used, column historgrams will be considered */
    end if;

  • Catching collection returned by function in SQL statement

    I am having a select query as : (I need all the values returned by the function in the select list)
    select t1.col1,t2.col2, (select t.a,t.b,t.c from fn(t2.col3) t)
    from
    t1,t2
    where t1.col1=t2.col2;
    My function is like :
    fn(t2.col3) returns a table in object format
    Here I was able to select only one value from table returned by the funcation at a time.If I select all the values as above it was giving too many vales error.
    Please any one help me in this

    user13044793 wrote:
    I am having a select query as : (I need all the values returned by the function in the select list)
    select t1.col1,t2.col2, (select t.a,t.b,t.c from fn(t2.col3) t)
    from
    t1,t2
    where t1.col1=t2.col2;Any specific reason for doing this? It adds an additional complexity to the SQL projection, and there's the additional costs of context switching to the PL/SQL engine (per row). All in all - not your typical approach and one that should have sound justification.
    As for the basic method - the multiset() SQL function needs to be used to create a collection. Here's a basic example of the approach:
    SQL> create or replace type TFoo as object(
      2          id      number,
      3          bar     varchar2(5)
      4  );
      5  /
    Type created.
    SQL>
    SQL> create or replace type TFooSet as table of TFoo;
      2  /
    Type created.
    SQL>
    SQL> create or replace function GetSomeFoo( n number ) return TFooSet is
      2          foo     TFooSet;
      3  begin
      4          foo := new TFooSet();
      5          foo.Extend( 5 );
      6 
      7          for i in 1..5
      8          loop
      9                  foo(i) := new TFoo( n+i-1, to_char(i-1,'0000') );
    10          end loop;
    11 
    12          return( foo );
    13  end;
    14  /
    Function created.
    SQL>
    SQL> select
      2          object_id,
      3          object_name,
      4          cast(
      5                  multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet
      6          )       as FOO
      7  from       all_objects
      8  where      owner = 'SYS'
      9  and        rownum <= 5;
    OBJECT_ID OBJECT_NAME                    FOO(ID, BAR)
         27538 /1000e8d1_LinkedHashMapValueIt TFOOSET(TFOO(27538, ' 0000'), TFOO(27539, ' 0001')
                                              , TFOO(27540, ' 0002'), TFOO(27541, ' 0003'), TFOO
                                              (27542, ' 0004'))
         28544 /1005bd30_LnkdConstant         TFOOSET(TFOO(28544, ' 0000'), TFOO(28545, ' 0001')
                                              , TFOO(28546, ' 0002'), TFOO(28547, ' 0003'), TFOO
                                              (28548, ' 0004'))
         11718 /10076b23_OraCustomDatumClosur TFOOSET(TFOO(11718, ' 0000'), TFOO(11719, ' 0001')
                                              , TFOO(11720, ' 0002'), TFOO(11721, ' 0003'), TFOO
                                              (11722, ' 0004'))
         30094 /100c1606_StandardMidiFileRead TFOOSET(TFOO(30094, ' 0000'), TFOO(30095, ' 0001')
                                              , TFOO(30096, ' 0002'), TFOO(30097, ' 0003'), TFOO
                                              (30098, ' 0004'))
        684122 /1023e902_OraCharsetUTFE       TFOOSET(TFOO(684122, ' 0000'), TFOO(684123, ' 0001
                                              '), TFOO(684124, ' 0002'), TFOO(684125, ' 0003'),
                                              TFOO(684126, ' 0004'))
    SQL>
    SQL> with dataset as(
      2          select
      3                  object_id,
      4                  object_name,
      5                  cast(
      6                          multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet
      7                  )                as FOO
      8          from    all_objects
      9          where   owner = 'SYS'
    10          and     rownum <= 5
    11  )
    12  select
    13          d.object_id,
    14          d.object_name,
    15          f.id,
    16          f.bar
    17  from   dataset d,
    18          table(d.foo) f
    19  /
    OBJECT_ID OBJECT_NAME                            ID BAR
           217 DUAL                                  217  0000
           217 DUAL                                  218  0001
           217 DUAL                                  219  0002
           217 DUAL                                  220  0003
           217 DUAL                                  221  0004
           268 SYSTEM_PRIVILEGE_MAP                  268  0000
           268 SYSTEM_PRIVILEGE_MAP                  269  0001
           268 SYSTEM_PRIVILEGE_MAP                  270  0002
           268 SYSTEM_PRIVILEGE_MAP                  271  0003
           268 SYSTEM_PRIVILEGE_MAP                  272  0004
           271 TABLE_PRIVILEGE_MAP                   271  0000
           271 TABLE_PRIVILEGE_MAP                   272  0001
           271 TABLE_PRIVILEGE_MAP                   273  0002
           271 TABLE_PRIVILEGE_MAP                   274  0003
           271 TABLE_PRIVILEGE_MAP                   275  0004
           274 STMT_AUDIT_OPTION_MAP                 274  0000
           274 STMT_AUDIT_OPTION_MAP                 275  0001
           274 STMT_AUDIT_OPTION_MAP                 276  0002
           274 STMT_AUDIT_OPTION_MAP                 277  0003
           274 STMT_AUDIT_OPTION_MAP                 278  0004
           815 RE$NV_LIST                            815  0000
           815 RE$NV_LIST                            816  0001
           815 RE$NV_LIST                            817  0002
           815 RE$NV_LIST                            818  0003
           815 RE$NV_LIST                            819  0004
    25 rows selected.
    SQL>

  • Audit All DML and DDL on an Application Schema

    Hello;
    I have a requirement to audit all DML and DDL on an Application Schema (Lets say SCOTT). I have set:
    ALTER SYSTEM SET audit_trail = XML, EXTENDED scope=spfile; -- Want my audit log on the OS with Bind and SQL.
    ALTER SYSTEM SET AUDIT_SYS_OPERATIONS = TRUE scope=spfile; -- Want to audit sysdba and sysoper activity
    audit create session; -- Want to see both logins and failed logins
    How would I get all DML and DDL on an Application Schema (SCOTT)?
    I am using 11iR1 Standard Edition.

    Have look at system_privilege_map and find all the options you need to audit...
    or you can use the below script..
    SELECT 'audit ' ||LOWER(name) || ' by app_user;'
    FROM system_privilege_map;
    if you want to filter-out the one you have already audited, then use dba_priv_audit_opts ...
    Hope this info will be useful to you...
    Thanks,

  • Granting Pvivileges on a schema

    grant all on schema schemaname to user
    when i execute this command missing keyword error is shown..how can i resolve??

    Thats qustion pertaining to database section as it your first post so i am answering you becareful next time
    SQL>
    SQL> sho user
    USER is "SYSTEM"
    SQL> select * from system_privilege_map
    2 where name like '%PRIV%';
    PRIVILEGE NAME PROPERTY
    -167 GRANT ANY PRIVILEGE 0
    -244 GRANT ANY OBJECT PRIVILEGE 0
    SQL>
    SQL> -- Create a new user with just create session (to log on) and grant
    SQL> -- any privilege to, well grant all privileges.
    SQL> create user emil identified by emil;
    User created.
    SQL> grant create session, grant any privilege to emil;
    Grant succeeded.

  • Parallel Execution in Oracle

    Hi,
    I have source data which keeps on populating.I want to process the records parallely using Oracle Stored Procedure.I should not reprocess the records that are already processed.Please suggest an logic.
    Right now i have only option of calling the procedure multiple times in unix environment.
    Regards,
    Venkat

    An example of how to create a worloads table that enables target table (to process) to be chunked, and processed.
    SQL> --// we have a table with a PK that is not a gap-free
    SQL> --// sequential number
    SQL> create table sample_data(
      2          id              primary key,
      3          last_update,
      4          name
      5  ) organization index
      6  nologging as
      7  select
      8          object_id,
      9          sysdate,
    10          object_name
    11  from       all_objects
    12  /
    Table created.
    SQL>
    SQL> --// first couple of rows - as can be seen, we cannot
    SQL> --// use id column ranges as the 1-1000 range could be
    SQL> --// 10 rows, the 1001-2000 range 1 row, and the 2001-3000
    SQL> --// range 900 rows.
    SQL> select * from(
      2          select * from sample_data order by 1
      3  ) where rownum < 11;
            ID LAST_UPDATE         NAME
           100 2013/07/08 09:10:01 ORA$BASE
           116 2013/07/08 09:10:01 DUAL
           117 2013/07/08 09:10:01 DUAL
           280 2013/07/08 09:10:01 MAP_OBJECT
           365 2013/07/08 09:10:01 SYSTEM_PRIVILEGE_MAP
           367 2013/07/08 09:10:01 SYSTEM_PRIVILEGE_MAP
           368 2013/07/08 09:10:01 TABLE_PRIVILEGE_MAP
           370 2013/07/08 09:10:01 TABLE_PRIVILEGE_MAP
           371 2013/07/08 09:10:01 STMT_AUDIT_OPTION_MAP
           373 2013/07/08 09:10:01 STMT_AUDIT_OPTION_MAP
    10 rows selected.
    SQL>
    SQL> --// we create a workloads table - we'll use this to
    SQL> --// hand out work to a parallel process
    SQL> create table workloads(
      2          workload_name   varchar2(30),
      3          workload_id     number,
      4          workload_data   number,
      5          constraint pk_workloads primary key
      6          ( workload_name, workload_id )
      7  ) organization index
      8  /
    Table created.
    SQL>
    SQL> --// we create the workloads (1 workload per rows in
    SQL> --// this example) for processing the sample_data table
    SQL> insert into workloads
      2  select
      3          'SampleData1',
      4          rownum,
      5          id
      6  from       sample_data;
    57365 rows created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> --// we can now chunk the SampleData1 workload using the
    SQL> --// workload_id as it is a sequential gap free number to
    SQL> --// use for even distribution of work
    SQL> col VALUE format 999,999,999
    SQL> select 'Start at ' as "LABEL", min(workload_id) as  "VALUE" from workloads where workload_name = 'SampleData1'
      2  union all
      3  select 'End at ', max(workload_id) from workloads where workload_name = 'SampleData1'
      4  union all
      5  select 'For rowcount ', count(*) from workloads where workload_name = 'SampleData1'
      6  /
    LABEL                VALUE
    Start at                 1
    End at              57,365
    For rowcount        57,365
    SQL>
    SQL> --// for example, we want to create 10 workload buckets and
    SQL> --// fill each with a range of workload identifiers
    SQL> with workload_totals( start_id, end_id ) as(
      2          select min(workload_id), max(workload_id) from workloads where workload_name = 'SampleData1'
      3  ),
      4  buckets_needed( b ) as(
      5          select ceil(end_id/10) from workload_totals
      6  ),
      7  buckets( workload_id, bucket) as (
      8          select workload_id, ceil(workload_id/b) from workloads, buckets_needed where workload_name = 'SampleData1'
      9          order by 1
    10  )
    11  select
    12          row_number() over(order by min(workload_id))    as BUCKET,
    13          min(workload_id)                                as START_WORLOAD_ID,
    14          max(workload_id)                                as END_WORKLOAD_ID
    15  from       buckets
    16  group by bucket
    17  order by 1
    18  /
        BUCKET START_WORLOAD_ID END_WORKLOAD_ID
             1                1            5737
             2             5738           11474
             3            11475           17211
             4            17212           22948
             5            22949           28685
             6            28686           34422
             7            34423           40159
             8            40160           45896
             9            45897           51633
            10            51634           57365
    10 rows selected.
    SQL>
    SQL> --// we need now a procedure that will work as a thread and be called, in
    SQL> --// parallel, to process a workload bucket
    SQL> create or replace procedure ProcessWorkload(
      2          workloadName    varchar2,
      3          startID         number,
      4          endID           number
      5  ) is
      6  begin
      7          --// we make this simple - we read the workload data from
      8          --// workloads table and do an update of sample data
      9          update(
    10                  select
    11                          s.*
    12                  from    sample_data s
    13                  where   s.id in(
    14                          select
    15                                  w.workload_data
    16                          from    workloads w
    17                          where   w.workload_name = 'SampleData1'
    18                          and     w.workload_id between startID and endID
    19                  )
    20          )
    21          set     name = lower(name),
    22                  last_update = sysdate;
    23  end;
    24  /
    Procedure created.
    SQL>
    SQL> --// process sample_data in parallel via 10 workload buckets, using 2
    SQL> --// parallel processes
    SQL> var c refcursor
    SQL> declare
      2          taskName        varchar2(30);
      3  begin
      4          taskName := 'Parallel-PQ-Process1';
      5          DBMS_PARALLEL_EXECUTE.create_task( taskName );
      6
      7          --// we use our SQL above to create 10 buckets, with each bucket
      8          --// (or chunk) specifying the start and end workload id's to
      9          --// process
    10          DBMS_PARALLEL_EXECUTE.create_chunks_by_sql(
    11                  task_name => taskName,
    12                  sql_stmt =>
    13                          'with workload_totals( start_id, end_id ) as(
    14                                  select min(workload_id), max(workload_id) from workloads where workload_name = ''SampleData1''
    15                          ),
    16                          buckets_needed( b ) as(
    17                                  select ceil(end_id/10) from workload_totals
    18                          ),
    19                          buckets( workload_id, bucket) as (
    20                                  select workload_id, ceil(workload_id/b) from workloads, buckets_needed where workload_name = ''SampleData1''
    21                                  order by 1
    22                          )
    23                          select
    24                                  min(workload_id),
    25                                  max(workload_id)
    26                          from    buckets
    27                          group by bucket ',
    28                  by_rowid => false
    29          );
    30
    31          --// next we process the 10 buckets/chunks, two at a time
    32          DBMS_PARALLEL_EXECUTE.Run_Task(
    33                  task_name => taskName,
    34                  sql_stmt => 'begin ProcessWorkload(''SampleData1'',:start_id,:end_id); end;',
    35                  language_flag => DBMS_SQL.NATIVE,
    36                  parallel_level => 2
    37          );
    38
    39          --// wait for it to complete
    40          while DBMS_PARALLEL_EXECUTE.task_status( taskName ) != DBMS_PARALLEL_EXECUTE.Finished loop
    41                  DBMS_LOCK.Sleep(10);
    42          end loop;
    43
    44          --// stats cursor
    45          open :c for
    46          select
    47                  task_name,
    48                  job_name,
    49                  chunk_id,
    50                  status,
    51                  start_id,
    52                  end_id,
    53                  end_id-start_id                         as UPDATES_DONE,
    54                  to_char(start_ts,'hh24:mi:ss.ff')       as START_TS,
    55                  to_char(end_ts,'hh24:mi:ss.ff')         as END_TS,
    56                  end_ts-start_ts                         as DURATION
    57          from    user_parallel_execute_chunks
    58          where   task_name = taskName
    59          order by 1,2;
    60
    61          --// remove task
    62          DBMS_PARALLEL_EXECUTE.drop_task( taskName );
    63  end;
    64  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> col TASK_NAME format a20
    SQL> col JOB_NAME format a20
    SQL> col START_TS format a15
    SQL> col END_TS format a15
    SQL> col DURATION format a28
    SQL> print c
    TASK_NAME            JOB_NAME               CHUNK_ID STATUS       START_ID     END_ID UPDATES_DONE START_TS        END_TS          DURATION
    Parallel-PQ-Process1 TASK$_15266_1              5821 PROCESSED           1       5737         5736 09:10:19.066131 09:10:19.313965 +000000000 00:00:00.247834
    Parallel-PQ-Process1 TASK$_15266_1              5822 PROCESSED       28686      34422         5736 09:10:19.315984 09:10:19.682781 +000000000 00:00:00.366797
    Parallel-PQ-Process1 TASK$_15266_1              5823 PROCESSED        5738      11474         5736 09:10:19.684925 09:10:19.818145 +000000000 00:00:00.133220
    Parallel-PQ-Process1 TASK$_15266_1              5824 PROCESSED       17212      22948         5736 09:10:19.818694 09:10:19.950409 +000000000 00:00:00.131715
    Parallel-PQ-Process1 TASK$_15266_1              5830 PROCESSED       51634      57365         5731 09:10:20.605421 09:10:20.721599 +000000000 00:00:00.116178
    Parallel-PQ-Process1 TASK$_15266_1              5826 PROCESSED       40160      45896         5736 09:10:20.080270 09:10:20.214443 +000000000 00:00:00.134173
    Parallel-PQ-Process1 TASK$_15266_1              5827 PROCESSED       11475      17211         5736 09:10:20.217662 09:10:20.339758 +000000000 00:00:00.122096
    Parallel-PQ-Process1 TASK$_15266_1              5828 PROCESSED       34423      40159         5736 09:10:20.342242 09:10:20.453802 +000000000 00:00:00.111560
    Parallel-PQ-Process1 TASK$_15266_1              5829 PROCESSED       45897      51633         5736 09:10:20.454376 09:10:20.603116 +000000000 00:00:00.148740
    Parallel-PQ-Process1 TASK$_15266_1              5825 PROCESSED       22949      28685         5736 09:10:19.950975 09:10:20.079311 +000000000 00:00:00.128336
    10 rows selected.
    SQL>
    SQL> --// updated sample data
    SQL> select * from(
      2          select * from sample_data order by 1
      3  ) where rownum < 11;
            ID LAST_UPDATE         NAME
           100 2013/07/08 09:10:19 ora$base
           116 2013/07/08 09:10:19 dual
           117 2013/07/08 09:10:19 dual
           280 2013/07/08 09:10:19 map_object
           365 2013/07/08 09:10:19 system_privilege_map
           367 2013/07/08 09:10:19 system_privilege_map
           368 2013/07/08 09:10:19 table_privilege_map
           370 2013/07/08 09:10:19 table_privilege_map
           371 2013/07/08 09:10:19 stmt_audit_option_map
           373 2013/07/08 09:10:19 stmt_audit_option_map
    10 rows selected.
    SQL>
    To eliminate the workload table approach, you need to find an alternative method for chunking the target table. Whether such a method is available depends entirely on the structure and nature of your target table  (and is the preferred approach over using a secondary worktable to drive parallel processing).

  • Access quick migration error - missing privilege

    I'm trying to migrate an access 2000 db using the quick migrate, but when I do the pre-migration check I get a "FAILED" for "Checking target rights" - the information says "Missing privilege CREATE VIEW". The user has create view, so I'm not sure what's going on.
    Is there a way to get more details as to what causes this failure?

    just created a user:
    create user abc identified by abc;
    and granted only:
    grant connect,resource to abc;
    Now SQlDevMWB claims about missing create view privilege.
    So I granted also:
    grant create view to abc;
    and now it works well.
    So I would suggest you check the privileges manually using SQL*Plus.
    Here it would be best to define a view that collects all privileges:
    CREATE OR REPLACE VIEW DBA_USER_PRIVS (USERNAME, ROLENAME, PRIVILEGE) AS
    SELECT DECODE(SA1.GRANTEE#, 1, 'PUBLIC', U1.NAME), SUBSTR(U2.NAME,1,20),
    SUBSTR(SPM.NAME,1,27)
    FROM SYS.SYSAUTH$ SA1, SYS.SYSAUTH$ SA2, SYS.USER$ U1,
    SYS.USER$ U2, SYS.SYSTEM_PRIVILEGE_MAP SPM
    WHERE SA1.GRANTEE# = U1.USER#
    AND SA1.PRIVILEGE# = U2.USER#
    AND U2.USER# = SA2.GRANTEE#
    AND SA2.PRIVILEGE# = SPM.PRIVILEGE
    UNION
    SELECT U.NAME, NULL, SUBSTR(SPM.NAME,1,27)
    FROM SYS.SYSTEM_PRIVILEGE_MAP SPM, SYS.SYSAUTH$ SA, SYS.USER$ U
    WHERE SA.GRANTEE#=U.USER#
    AND SA.PRIVILEGE#=SPM.PRIVILEGE
    and now you can simply check:
    select * from dba_user_privs where username='ABC';
    What are the permissions for your user?

  • How To reduce UNDO records

    Scenario:
    Table A has 40 million records and table B has 30 million records.
    And we have standy Database so there is no option for using Nologging.
    Using Join and where clause i need to insert around 15 million records to table C.
    If we insert using select statement it will generate more UNDO records
    Please provide me the solution so that i can avoid UNDO as much as possibe.
    Regards
    Deepak S

    >>when u give create table as it will generate undo . my table consists of 15 million records . when we create table d as select * from tablename . It will generte more undo..
    My suggession is give the query in toad save the output in .dat file . using sqlloader we can import the data. So we can reduce the undo ....
    Hmmm, have you some clue about regular sqlloader generate less redo than CTAS ?
    We're agree about regular term since you have a standby databasen nologging operation should be avoid.
    Read the following test case. Note that I'm alone on the database, so all the redo generation are because my queries.
    First, test with CTAS method :
    SQL> select b.name, a.value
      2  from   v$sysstat a, v$statname b
      3  where  a.statistic#=b.statistic#
      4* and    b.name like '%redo size%'
    SQL> /
    NAME                                                                  VALUE
    redo size 846112
    SQL> select count(*) from all_objects;
      COUNT(*)
         41183
    SQL> create table myobjects as select * from all_objects;
    Table created.
    SQL> select b.name, a.value
      2  from   v$sysstat a, v$statname b
      3  where  a.statistic#=b.statistic#
      4* and    b.name like '%redo size%'
    SQL> /
    NAME                                                                  VALUE
    redo size 5672516
    SQL> select (5672516-846112)/1024/1024 from dual
    SQL> /
    (5672516-846112)/1024/1024
                    4,6028175CTAS generate around 4,6Mb redolog.
    Now, with your method. Creation of a data file :
    QL> set head off
    SQL> set pagesize 0
    SQL> set linesize 1000
    SQL> set trims on
    SQL> spool E:\Scripts\Sql\myobjects.dat
    SQL> select OWNER          ||';'||
                OBJECT_NAME    ||';'||
                SUBOBJECT_NAME ||';'||
                OBJECT_ID      ||';'||
                DATA_OBJECT_ID ||';'||
                OBJECT_TYPE    ||';'||
                CREATED        ||';'||
                LAST_DDL_TIME  ||';'||
                TIMESTAMP      ||';'||
                STATUS         ||';'||
                TEMPORARY      ||';'||
                GENERATED      ||';'||
                SECONDARY     
         from   myobjects;
    SYS;DUAL;;258;258;TABLE;30/08/05;30/08/05;2005-08-30:13:50:32;VALID;N;N;N
    PUBLIC;DUAL;;259;;SYNONYM;30/08/05;30/08/05;2005-08-30:13:50:32;VALID;N;N;N
    SYS;SYSTEM_PRIVILEGE_MAP;;311;311;TABLE;30/08/05;30/08/05;2005-08-30:13:50:34;VALID;N;N;N
    PUBLIC;SYSTEM_PRIVILEGE_MAP;;313;;SYNONYM;30/08/05;30/08/05;2005-08-30:13:50:34;VALID;N;N;N
    SYS;TABLE_PRIVILEGE_MAP;;314;314;TABLE;30/08/05;30/08/05;2005-08-30:13:50:34;VALID;N;N;N
    SQL> spool offThen a controlfile to use with sqlloader :
    E:\Scripts\Sql\myobjects.ctl
    LOAD DATA
    INFILE 'E:\Scripts\Sql\myobjects.dat'
    BADFILE 'E:\Scripts\Sql\myobjects.bad'
    DISCARDFILE 'E:\Scripts\Sql\myobjects.dsc'
    INTO TABLE myobjects
    FIELDS TERMINATED BY ';'
    (OWNER           CHAR(30),
    OBJECT_NAME     CHAR(30),
    SUBOBJECT_NAME  CHAR(30),
    OBJECT_ID       INTEGER EXTERNAL(22) NULLIF OBJECT_ID=BLANKS,
    DATA_OBJECT_ID  INTEGER EXTERNAL(22) NULLIF DATA_OBJECT_ID=BLANKS,
    OBJECT_TYPE     CHAR(19),
    CREATED         DATE(8) "DD/MM/YY" NULLIF CREATED=BLANKS,
    LAST_DDL_TIME   DATE(8) "DD/MM/YY" NULLIF LAST_DDL_TIME=BLANKS,
    TIMESTAMP       CHAR(19),
    STATUS          CHAR(7),
    TEMPORARY       CHAR(1),
    GENERATED       CHAR(1),
    SECONDARY       CHAR(1))Now, we create the empty table and check the redo amount before sqlloader :
    SQL> create table myobjects as select * from all_objects where 1=2;
    Table created.
    SQL> select b.name, a.value
      2  from   v$sysstat a, v$statname b
      3  where  a.statistic#=b.statistic#
      4  and    b.name like '%redo size%'
      5  /
    NAME                                                                  VALUE
    redo size 6236212Run the sqlloader :
    E:\oracle\ora102\BIN>sqlldr scott/demo102 control=E:\Scripts\Sql\myobjects.ctl
    Commit point reached - logical record count 40897
    Commit point reached - logical record count 40961
    Commit point reached - logical record count 41025
    Commit point reached - logical record count 41089
    Commit point reached - logical record count 41153
    Commit point reached - logical record count 41183
    Commit point reached - logical record count 41184Last, check the redo amount and compare with previous amount :
    SQL> select b.name, a.value
      2  from   v$sysstat a, v$statname b
      3  where  a.statistic#=b.statistic#
      4  and    b.name like '%redo size%'
      5  /
    NAME                                                                  VALUE
    redo size 11196136
    SQL> select (11196136-6236212)/1024/1024 from dual;
    (11196136-6236212)/1024/1024
                      4,73015213
    SQL> select count(*) from myobjects;
         41184
    SQL> SQL*Loader generate around 4,7Mb.
    To resume the redo amount generation :
    1. CTAS ~ 4,6Mb
    2. SQL*Loader ~ 4,7Mb
    What you said in your last post :
    My suggession is give the query in toad save the output in .dat file . using sqlloader we can import the data. So we can reduce the undo ...Are you still sure now ?
    Nicolas.
    Well, I'm sorry, you said about undo and me about redo...
    Message was edited by:
    N. Gasparotto

  • Export query syntax

    Hi,,
    i want export one table with query option.
    my whrere conditions is where v_Customer_code in ('3658','3640','7463','7134','7195','8318','8181')
    please any one help me what is the syntax to export table..
    i am using 10g databse on hp-ux box.
    Regards,
    Mugu

    If you run exp under Windows, try:
    exp <user>/<password> tables=<your table name> query='where v_Customer_code in ('3658','3640','7463','7134','7195','8318','8181')'where <user> is the Oracle account name of the table you want to export.
    Example:
    C:\>sqlplus test/test
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 10 13:20:11 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> select * from t;
             X Y
           258 DUAL
           259 DUAL
           311 SYSTEM_PRIVILEGE_MAP
           313 SYSTEM_PRIVILEGE_MAP
           314 TABLE_PRIVILEGE_MAP
           316 TABLE_PRIVILEGE_MAP
           317 STMT_AUDIT_OPTION_MAP
           319 STMT_AUDIT_OPTION_MAP
           605 MAP_OBJECT
           886 RE$NV_LIST
           887 STANDARD
             X Y
           889 DBMS_STANDARD
           890 DBMS_STANDARD
           901 V$MAP_LIBRARY
           903 V$MAP_FILE
           905 V$MAP_FILE_EXTENT
           907 V$MAP_ELEMENT
           909 V$MAP_EXT_ELEMENT
           911 V$MAP_COMP_LIST
           913 V$MAP_SUBELEMENT
    20 rows selected.
    SQL> exit
    Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    C:\>exp test/test tables=t query='where x in (258,259)'
    Export: Release 10.2.0.1.0 - Production on Fri Sep 10 13:20:33 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Export done in US7ASCII character set and AL16UTF16 NCHAR character set
    server uses WE8MSWIN1252 character set (possible charset conversion)
    About to export specified tables via Conventional Path ...
    . . exporting table                              T          2 rows exported
    Export terminated successfully without warnings.
    C:\>

Maybe you are looking for

  • Canon 5D  digital camera not able to connect with EOS utiliities software

    I use the Canon 5D camera and have a Macbook pro which I got about 3 months ago. I use Canons EOS utilities for this purpose. When the camera is tethered to the computer, you start the software and when an exposure is made, Image browser is opened by

  • If I restore my iphone from back up will I lose my current data?

    I backed my phonne up to itunes and  I would like to restore that data (since then somethings that were backed up have been deleted) but those are the things I would like to retreive I just don't want to lose things that haven't been backed up if tha

  • How to get the Background job name

    Hi, I am executing a report in background and i want to get the background job name in the same report program. How can i get the same. Regards, Rajgopal Dara.

  • ItemUpdate Webservice with alternates

    Hi, I have a need to start using Item alternates from our ERP system (non-SAP). I am using version 6.0.4.22. I tried to use the tag <Me:ItemAlternateList> in the ItemService.UpdateItem method, but for some reason I never get the Alternate item to be

  • Installing 10.2 error message at processing essential system software.

    Due to some type of software glitch I have had to reinstall my OS X software. I am able to make it to certain parts of the install before I am given the "error installing software, please try again" The furthest I am able to go is about 20 % in at th