Purge tables

Hi,
How can we purge/reset tables (data) like v$sql, v$sqlarea and all others apart from restarting the instance?
Thanks!

Hans Forbrich wrote:
bLaK wrote:
How can we purge/reset tables (data) like v$sql, v$sqlarea and all others apart from restarting the instance?Why?
Those internal tables contain a lot of information about your system - memory, functions, statistics, etc. and many are derived directly from the memory of the system, not from disk tables. Since they are your window into the kernel (similar to /proc for Linux), minor nit to pick.
The V$ views are memory data structures within Oracle's SGA; not OS kernel.

Similar Messages

  • Purging tables getting stuck?

    Oracle 10.1.0.3 & 10.1.0.4 (Linux AMD64).
    I have an often occurring problem on several Oracle SE platforms - a data management PL/SQL job that among other things, create new tables and drop old tables. Yeah I know this is not the best of ideas, but without partitioning this is the only way to create and maintain a sliding window period - by creating individual tables instead of adding new partitions...
    Regularly, such a job will spin forever on a wait even called enq: RO - fast object reuse.
    Metalink and Google searches have not turned up anything much. Nor has posting about the problem here... Seems like a pretty much unknown event.
    Recently doing some stuff on an Oracle EE platform and I start to butt my head into this again.. and only when using the PURGE clause for the DROP TABLE statement. And that is exactly what those SE data management jobs do too - they drop and purge tables outside the sliding window period.
    Thus it would seem that the problem is related to the PURGE clause.
    Anyone with similar experiences or ideas as to what the underlaying problem can be? Any special disclaimers/technical issues raised via Metalink notes regarding the PURGE clause?
    Thanks.

    > I believe the RO enqueue is associated with code that tries to clear the buffer
    cache of clean blocks belonging to the object. You might find more about it with a
    search on comp.databases.oracle.server.
    Thanks Joanathan, As for comp.databases.oracle.server... I do miss the old stomping grounds but IT security here, in all their oh--so-wise and infinite wisdom, has blocked access to the whole of Usenet.
    > A strategy that may help is to remove the PURGE from the drop, and dispatch a
    job that does a "purge recyclebin" at some later time - with the hope that by the
    time the "real" drop happens there won't be any buffered blocks for that object to
    cause a problem.
    Yeah.. that will well be worth a try and is simple to implement.

  • INVENTORY TRANSACTION PURGE시 해당 TABLE들의 정보

    제품 : MFG_INV
    작성날짜 : 2004-05-20
    INVENTORY TRANSACTION PURGE 시 해당 TABLE들의 정보
    ===========================================
    PURPOSE
    Inventory Transaction Purge에 의해 삭제되는 data들을
    파악하고자 한다.
    Problem Description
    Inventory module의 Transaction Purge시 다음의
    Table들은 정상적으로 Purge된다.
    MTL_MATERIAL_TRANSACTIONS
    MTL_TRANSACTION_LOT_NUMBERS
    MTL_UNIT_TRANSACTIONS
    MTL_TRANSACTION_ACCOUNTS
    MTL_MATERIAL_TXN_ALLOCATIONS
    다음의 table들은 Purge대상에서 제외되어 있다.
    wip_scrap_values
    mtl_cst_actual_cost_details
    mtl_cst_txn_cost_details
    MTL_ACTUAL_COST_SUBELEMENT
    Workaround
    N/A
    Solution Description
    Applied a Patch#2165174. fixed in 11.5.9
    이 Patch에 의해 위에 언급한 모든 table들에 대해
    정상적으로 Purge된다.
    Reference Documents
    Bug2165174

  • How to purge tables using odi ???

    hi,
    I want to purge the Data in target table.my Data Policy is to only retain the only 90 days. I have to keep only 90 days data. How can i do this in ODI. I have only one DATE column.
    Thanks,
    Regards,
    AMSII

    If your existing date field can be used to identify the records to be purged, then you could simply create a procedure in ODI along the lines of
    delete from <%=odiRef.getSchemaName( )%>.*your_table* where your_date_field < (sysdate - 90)
    This is the simplest way, but be wary of your indexes on the table that they don't get too fragmented. You could also investigate using a daily partition startegy on the table which would enable you to drop partitions older than 90 days which would be much faster.

  • What is the purging mechanism on historical tables during 80%

    Hi,
    I have a UCCE 7.2.5 environment.  Lately the HDS database is reaching 80% usage threshold and the system started to purge the database automatically.
    Realised the auto purge is always purging for a few tables only.  Can someone advise how the auto purge works?
    Appreciate your help in advanced.
    Thanks.
    regards,

    Hi Joe,
    Thanks for the info.  You mentioned "purge the oldest data in alphabetical order", does it mean the following table order?
    - t_Agent_Half_Hour: 615
    - t_Agent_Logout: 2
    - t_Agent_Skill_Group_Half_Hour: 615
    - t_Agent_Skill_Group_Logout: 2
    - t_Agent_State_Trace: 36
    - t_Call_Type_Half_Hour: 10
    - t_Network_Trunk_Group_Half_Hour: 780
    - t_Peripheral_Half_Hour: 781
    - t_Physical_Controller_Half_Hou: 781
    - t_Route_Call_Detail: 1
    - t_Route_Call_Variable: 1
    - t_Route_Half_Hour: 781
    - t_Routing_Client_Five_Minute: 781
    - t_Service_Half_Hour: 781
    - t_Skill_Group_Half_Hour: 781
    - t_Termination_Call_Detail: 28
    - t_Termination_Call_Variable: 1
    - t_Trunk_Group_Half_Hour: 780
    If you take a close look, the 615, 2, 36, 10 etc are actually the different day of data till date.  For example, t_Call_Type_Half_Hour table has data upto 10 days only.
    If the purge method mentioned earlier is true, the t_Agent_Half_Hour table should be the first to purge?  But in real case, the purging tables are in random order.
    Please advise.
    Thanks.
    regards,

  • Can not recover table from rman backup

    For testing I want to recover deleted table from rman backup.
    I have make vm of oracle 11g.  the following step i have applied but could not recover the table.
    rman> backup database ;
    On sqlplus create login as scott/tiger
    create table scott.emp1(col1 varchar2(10));
    insert into emp1(col1) value('Yasir ') ;
    commit ;
    select * from emp1 ;
    it shows me one row successfully.
    Now i have login the  sys as sysdba
    sqlplus> alter system switch logfile ;
    after this i have drop the table .
    Now to recover the table i have restored database on same vm.
    rman>restore database ;
    rman> recover database ;
    rman> alter database open ;
    on sqlplus i have issued
    sqlplus> select * from scott.emp1 ;
    table or view does not exist.
    any help how to recover the deleted table from rman backup

    Hi,
    Check this test case
    SQL> create table TEST2 as select * from emp;
    Table created.
    SQL> select count(*) from TEST2;
      COUNT(*)
            15
    SQL> select TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS') from dual;
    TO_CHAR(SYSDATE,'DD-
    10-SEP-2013 10:57:05
    SQL> alter system switch logfile;
    System altered.
    SQL> drop table TEST2 purge;
    Table dropped.
    SQL> shu immediate
    [oracle@vnode MYSHELL]$ rman target /
    Recovery Manager: Release 11.2.0.2.0 - Production on Tue Sep 10 10:58:39 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    connected to target database: DDTEST (DBID=1667776968, not open)
    RMAN> run{
    set until time "to_date('2013 Sep 10 10:57','yyyy mon dd hh24:mi')";
    restore database;
    recover database;
    alter database open resetlogs;
    }2> 3> 4> 5> 6>
    media recovery complete, elapsed time: 00:00:02
    Finished recover at 10-SEP-13
    database opened
    RMAN> exit
    SQL> set lin 200 pages 100
    SQL> select count(*) from test2;
      COUNT(*)
            15
    HTH

  • Moving Subpartitions to a duplicate table in a different schema.

    +NOTE: I asked this question on the PL/SQL and SQL forum, but have moved it here as I think it's more appropriate to this forum. I've placed a pointer to this post on the original post.+
    Hello Ladies and Gentlemen.
    We're currently involved in an exercise at my workplace where we are in the process of attempting to logically organise our data by global region. For information, our production database is currently at version 10.2.0.3 and will shortly be upgraded to 10.2.0.5.
    At the moment, all our data 'lives' in the same schema. We are in the process of producing a proof of concept to migrate this data to identically structured (and named) tables in separate database schemas; each schema to represent a global region.
    In our current schema, our data is range-partitioned on date, and then list-partitioned on a column named OFFICE. I want to move the OFFICE subpartitions from one schema into an identically named and structured table in a new schema. The tablespace will remain the same for both identically-named tables across both schemas.
    Do any of you have an opinion on the best way to do this? Ideally in the new schema, I'd like to create each new table as an empty table with the appropriate range and list partitions defined. I have been doing some testing in our development environment with the EXCHANGE PARTITION statement, but this requires the destination table to be non-partitioned.
    I just wondered if, for partition migration across schemas with the table name and tablespace remaining constant, there is an official "best practice" method of accomplishing such a subpartition move neatly, quickly and elegantly?
    Any helpful replies welcome.
    Cheers.
    James

    You CAN exchange a subpartition into another table using a "temporary" (staging) table as an intermediary.
    See :
    SQL> drop table part_subpart purge;
    Table dropped.
    SQL> drop table NEW_part_subpart purge;
    Table dropped.
    SQL> drop table STG_part_subpart purge;
    Table dropped.
    SQL>
    SQL> create table part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition p_1 values less than (10) (subpartition p_1_s_1 values ('A'), subpartition p_1_s_2 values ('B'), subpartition p_1_s_3 values ('C'))
      5  ,
      6  partition p_2 values less than (20) (subpartition p_2_s_1 values ('A'), subpartition p_2_s_2 values ('B'), subpartition p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create index part_subpart_ndx on part_subpart(col_1) local;
    Index created.
    SQL>
    SQL>
    SQL> insert into part_subpart values (1,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'C');
    1 row created.
    SQL> insert into part_subpart values (11,'A');
    1 row created.
    SQL> insert into part_subpart values (11,'C');
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> create table NEW_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition n_p_1 values less than (10) (subpartition n_p_1_s_1 values ('A'), subpartition n_p_1_s_2 values ('B'), subpartition n_p_1_s_3 values ('C'))
      5  ,
      6  partition n_p_2 values less than (20) (subpartition n_p_2_s_1 values ('A'), subpartition n_p_2_s_2 values ('B'), subpartition n_p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create table STG_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  /
    Table created.
    SQL>
    SQL> -- ensure that the Staging table is empty
    SQL> truncate table STG_part_subpart;
    Table truncated.
    SQL> -- exchanging a subpart out of part_subpart
    SQL> alter table part_subpart exchange subpartition
      2  p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL> -- exchanging the subpart into NEW_part_subpart
    SQL> alter table NEW_part_subpart exchange subpartition
      2  n_p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL>
    SQL>
    SQL> select * from NEW_part_subpart subpartition (n_p_2_s_1);
         COL_1 COL_2
            11 A
    SQL>
    SQL> select * from part_subpart subpartition (p_2_s_1);
    no rows selected
    SQL>I have exchanged subpartition p_2_s_1 out of the table part_subpart into the table NEW_part_subpart -- even with a different name for the subpartition (n_p_2_s_1) if so desired.
    NOTE : Since your source and target tables are in different schemas, you will have to move (or copy) the staging table STG_part_subpart from the first schema to the second schema after the first "exchange subpartition" is done. You will have to do this for every subpartition to be exchanged.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Apr 4, 2011 10:19 AM
    Added clarification for cross-schema exchange.

  • Unknown table--- BIN$q9sxdXaDQgWvL8DWKxQFbw==$0

    I found the following unknown table in my scott/tiger instance.this table is named as
    BIN$q9sxdXaDQgWvL8DWKxQFbw==$0
    i am unable to run desc command or drop command on this table
    looking for some help regarding this
    thanks and regards

    Hi,
    Oracle introduce the concept of Recyclebin in 10g,whenever u drop the tables from schema then it automatically move to recyclebin and its names has changes with bin+some uq identifier,now in 10g ,after droping the tables from schema u can easily recover it by issuing one command.
    and if u want to be purge this table then use
    PURGE TABLE BIN$q9sxdXaDQgWvL8DWKxQFbw==$0;
    http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10739/tables.htm#sthref2018
    Kuljeet

  • Unable to descripe the table and unable to drop the table

    Hi,
    I have a temp table that we use like staging table to import the data in to the main table through some scheduled procedures.And that will dropped every day and will be created through the script.
    Some how while I am trying to drop the table manually got hanged, There after I could not find that table in dba_objects, dba_tables or any where.
    But Now I am unable to create that table manually(Keep on running the create command with out giving any error), Even I am not getting any error (keep on running )if I give drop/desc of table.
    Can you please any one help on this ? Is it some where got stored the table in DB or do we any option to repair the table ?
    SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE,STATUS from dba_objects where OBJECT_NAME like 'TEMP%';
    no rows selected
    SQL> desc temp
    Thank in advance.

    Hi,
    if this table drops then it moved DBA_RECYCLEBIN table. and also original name of its changed automatically by oracle.
    For example :
    SQL> create table tst (col varchar2(10), row_chng_dt date);
    Table created.
    SQL> insert into tst values ('Version1', sysdate);
    1 row created.
    SQL> select * from tst ;
    COL        ROW_CHNG
    Version1   16:10:03
    If the RECYCLEBIN initialization parameter is set to ON (the default in 10g), then dropping this table will place it in the recyclebin:
    SQL> drop table tst;
    Table dropped.
    SQL> select object_name, original_name, type, can_undrop as "UND", can_purge as "PUR", droptime
      2  from recyclebin
    SQL> /
    OBJECT_NAME                    ORIGINAL_NAME TYPE  UND PUR DROPTIME
    BIN$HGnc55/7rRPgQPeM/qQoRw==$0 TST           TABLE YES YES 2013-10-08:16:10:12
    All that happened to the table when we dropped it was that it got renamed. The table data is still there and can be queried just like a normal table:
    SQL> alter session set nls_date_format='HH24:MI:SS' ;
    Session altered.
    SQL> select * from "BIN$HGnc55/7rRPgQPeM/qQoRw==$0" ;
    COL        ROW_CHNG
    Version1   16:10:03
    Since the table data is still there, it's very easy to "undrop" the table. This operation is known as a "flashback drop". The command is FLASHBACK TABLE... TO BEFORE DROP, and it simply renames the BIN$... table to its original name:
    SQL> flashback table tst to before drop;
    Flashback complete.
    SQL> select * from tst ;
    COL        ROW_CHNG
    Version1   16:10:03
    SQL> select * from recyclebin ;
    no rows selected
    It's important to know that after you've dropped a table, it has only been renamed; the table segments are still sitting there in your tablespace, unchanged, taking up space. This space still counts against your user tablespace quotas, as well as filling up the tablespace. It will not be reclaimed until you get the table out of the recyclebin. You can remove an object from the recyclebin by restoring it, or by purging it from the recyclebin.
    SQL> select object_name, original_name, type, can_undrop as "UND", can_purge as "PUR", droptime
      2  from recyclebin
    SQL> /
    OBJECT_NAME                    ORIGINAL_NAME TYPE                      UND PUR DROPTIME
    BIN$HGnc55/7rRPgQPeM/qQoRw==$0 TST           TABLE                     YES YES 2006-09-01:16:10:12
    SQL> purge table "BIN$HGnc55/7rRPgQPeM/qQoRw==$0" ;
    Table purged.
    SQL> select * from recyclebin ;
    no rows selected
    Thank you
    And check this link:
    http://www.orafaq.com/node/968
    http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables011.htm
    Thank you

  • Doubt with creation of table!

    Hi Friends,
    I Have studied that we cannot create tables with that the name of ORACLE SERVER RESERVED clause like select,insert etc. Recenty i came across a query
    Create table TIMESTAMP (
                             ENO NUMBER(1)
                           );TIMESTAMP is a datatype but the table gets created without any errors.
    In this example
    create table "SELECT" (
                            ENO NUMBER(1)
                          );How does oracle differntiate it from the table name and the SELECT clause. I could not understand the logic also of what difference does it make when u give the table name in double quotes.
    Regards,
    Manoj

    Hi,
    This is very important.
    >
    "Nonquoted identifiers cannot be Oracle Database reserved words. Quoted identifiers can be reserved words, although this is not recommended."
    >
    Why? because I don't know about someone that type sql statements with object names between " ". So, anybody can waste a lot of time trying to indetify why the table name is invalid or they think that need to be grented by the correct privileges. So, if you put an object name in lower case between " " you need to referencing it with lower case, same case with upper case object name.
    SQL>create table "SELECT" (id number);
    Table created.
    SQL>select table_name from dba_tables where table_name = 'select';
    no rows selected
    SQL>select table_name from dba_tables where table_name = 'SELECT';
    TABLE_NAME
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    SELECT
    SQL>drop table "SELECT" purge;
    Table dropped.
    SQL>create table "select" (id number);
    Table created.
    SQL>select table_name from dba_tables where table_name = 'SELECT';
    no rows selected
    SQL>select table_name from dba_tables where table_name = 'select';
    TABLE_NAME
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    selectSo, that is very tiring.
    HTH -- johnxjean --

  • Inserting data in a table and checking

    create or replace procedure testpara1( p_IN in VARCHAR2,p_result out varchar2)
    Is
    CURSOR cur_key IS
          SELECT * FROM object_keywords;
    TYPE objkey_tab_type IS TABLE OF OBJECT_KEYWORDS%ROWTYPE;
    v_keywords  objkey_tab_type;
    v_keepwords varchar2(100);
    Begin
    INSERT INTO TEMP_TABLE
    VALUES(p_IN);
    COMMIT;
    OPEN cur_key;
           FETCH cur_key BULK COLLECT INTO v_keywords;
         CLOSE cur_key;
           FOR i IN v_keywords.FIRST .. v_keywords.LAST
             LOOP
                  v_keepwords := '%'||v_keywords(i).KEYWORDS||'%';
               select STOREVAL into p_result from TEMP_TABLE
               where CONTAINS(STOREVAL,'ahole') > 0;
    END LOOP;
    delete from TEMP_TABLE;
    commit;
    End  testpara1;here i m inserting a string a string in a table and trying to check that the present in object_keywords tabe is present in this string or not but showing error no data faound if also the desired data is present plz help me
    thanks in advance..
    Edited by: BluShadow on 24-May-2011 08:45
    added {noformat}{noformat} tags to keep formatting.  please read {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hmm.. i did some search on this. issue is probably due to index not sync with the table.
    Here is my test case
    SQL> drop table temp_table purge;
    Table dropped.
    SQL> create table temp_table
      2  (storeval varchar2(50));
    Table created.
    SQL> insert into temp_table
      2  values
      3  ('ahole is the word');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> CREATE INDEX temp1_idx ON temp_table
      2    (storeval
      3    ) indextype IS ctxsys.context;
    Index created.
    SQL> select * from temp_table where
      2  contains(storeval,'ahole') >0;
    STOREVAL
    ahole is the word
    SQL> delete from temp_table;
    1 row deleted.
    SQL> insert into temp_table
      2  values
      3  ('ahole is the word');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from temp_table where
      2  contains(storeval,'ahole') >0;
    no rows selectedYou might need to sync the index using ctx_ddl.SYNC_INDEX(<index_name>)
    SQL> exec ctx_ddl.SYNC_INDEX('temp1_idx');
    PL/SQL procedure successfully completed.
    SQL> select * from temp_table where
      2  contains(storeval,'ahole') >0;
    STOREVAL
    ahole is the wordHere's the link
    http://www.techxplore.net/2008/03/05/oracle-text-ctxsys-context-index-type-not-showing-search/
    Vivek L

  • SQL, PL/SQL functions, and ORA-04091 table is mutating

    Dears,
    Recently a question came up in an Oracle French forum about an insert/select that is throwing ORA-04091: table xxxx is mutating, trigger/function may not see it error in 11g while the same insert/select was working very well in 10g. The original poster gave a scenario that is easily reproducible. I am wondering what database release is correct the one throwing the error(11g) or the other one accepting the insert/select(10g)?
    *10g*
    mhouri.world > select * from v$version;
    BANNER                                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi               
    PL/SQL Release 10.2.0.4.0 - Production                                         
    CORE     10.2.0.4.0     Production                                                     
    TNS for Solaris: Version 10.2.0.4.0 - Production                               
    NLSRTL Version 10.2.0.4.0 - Production                                         
    mhouri.world > create table t_read_consistency (id number, vc varchar2(15), primary key (id));
    Table created.
    mhouri.world > insert into
      2        t_read_consistency
      3      select
      4        rownum id,
      5        rpad('a',15,'a')
      6      from
      7        dual
      8      connect by
      9        level<=1000;
    1000 rows created.
    mhouri.world > commit;
    Commit complete.
    mhouri.world > create or replace function f_read_consistency return varchar2
      2       as
      3        lv_vc  t_read_consistency.vc%type;
      4       begin
      5         select trc.vc
      6         into lv_vc
      7          from t_read_consistency trc
      8         where trc.id = 70 ;
      9        return lv_vc;
    10     end f_read_consistency;
    11    /
    Function created.
    mhouri.world >insert into
      2        t_read_consistency (id, vc)
      3      select
      4         1001
      5        ,f_read_consistency
      6      from dual;
          ,f_read_consistency
    ERROR at line 5:
    ORA-04091: table MHOURI.T_READ_CONSISTENCY is mutating, trigger/function may not see it
    ORA-06512: at "MHOURI.F_READ_CONSISTENCY", line 5
    _11g_
    mohamed@mhouri> select * from v$version;
    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                                         
    mohamed@mhouri> create table t_read_consistency (id number, vc varchar2(15), primary key (id));
    Table created.
    mohamed@mhouri> insert into
      2    t_read_consistency
      3  select
      4    rownum id,
      5    rpad('a',15,'a')
      6  from
      7    dual
      8  connect by
      9    level<=1000;
    1000 rows created.
    mohamed@mhouri>  create or replace function f_read_consistency return varchar2
      2   as
      3    lv_vc  t_read_consistency.vc%type;
      4   begin
      5     select trc.vc
      6     into lv_vc
      7      from t_read_consistency trc
      8     where trc.id = 70 ;
      9    return lv_vc;
    10  end f_read_consistency;
    11  /
    Function created.
    mohamed@mhouri> insert into
      2    t_read_consistency (id, vc)
      3  select
      4     1001
      5    ,f_read_consistency
      6  from dual;
      ,f_read_consistency
    ERROR at line 5:
    ORA-04091: table MOHAMED.T_READ_CONSISTENCY is mutating, trigger/function may
    not see it
    ORA-06512: at "MOHAMED.F_READ_CONSISTENCY", line 5 So far so good. Same behaviour for both releases. But let's bring a small change to the PL/SQL function to be as close as the example given in the French Forum
    _10g where the select/insert was working without error_:
    mhouri.world > select * from v$version;
    BANNER                                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi               
    PL/SQL Release 10.2.0.4.0 - Production                                         
    CORE     10.2.0.4.0     Production                                                     
    TNS for Solaris: Version 10.2.0.4.0 - Production                               
    NLSRTL Version 10.2.0.4.0 - Production       
    mhouri.world > create type t_read_cs as object (id number,vc varchar2(15));
      2  /
    Type created.
    mhouri.world > create type t_read_cs_tab  as table of t_read_cs;
      2  /
    Type created.
    mhouri.world > create or replace function f_read_consistency_tab
      2  return t_read_cs_tab
      3    as
      4      lc_t_read_cs_tab t_read_cs_tab := t_read_cs_tab();
      5      j  binary_integer := 0;
      6    begin
      7        for x in (select
      8                      id,
      9                      vc
    10                   from  t_read_consistency trs
    11                  where trs.id <= 10
    12       ) loop
    13 
    14          j := j +1;
    15          lc_t_read_cs_tab.extend;
    16          lc_t_read_cs_tab(j) := t_read_cs(x.id, x.vc);
    17     end loop;
    18     RETURN lc_t_read_cs_tab;
    19   end f_read_consistency_tab;
    20  /
    Function created.
    mhouri.world > select count(1) from t_read_consistency;
      COUNT(1)                                                                                                             
          1000                                                                                                             
    mhouri.world > select count(1)
      2  from (select * from table(f_read_consistency_tab));
      COUNT(1)                                                                                                             
            10                                                                                                             
    mhouri.world > insert into t_read_consistency
      2         (id,vc)
      3      select id,vc
      4   from table(f_read_consistency_tab)
      5  ;
    10 rows created.
    mhouri.world > select count(1) from t_read_consistency;
      COUNT(1)                                                                                                             
          1010            
    _11g where the same insert/select is throwing an error:_
    mohamed@mhouri> select * from v$version;
    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
    mohamed@mhouri> create type t_read_cs as object (id number,vc varchar2(15));
      2  /
    Type created.
    mohamed@mhouri> create type t_read_cs_tab  as table of t_read_cs;
      2  /
    Type created.
    mohamed@mhouri> create or replace function f_read_consistency_tab
      2      return t_read_cs_tab
      3        as
      4          lc_t_read_cs_tab t_read_cs_tab := t_read_cs_tab();
      5          j  binary_integer := 0;
      6        begin
      7            for x in (select
      8                          id,
      9                          vc
    10                      from  t_read_consistency trs
    11                     where trs.id <= 10
    12          ) loop
    13 
    14            j := j +1;
    15             lc_t_read_cs_tab.extend;
    16             lc_t_read_cs_tab(j) := t_read_cs(x.id, x.vc);
    17        end loop;
    18        RETURN lc_t_read_cs_tab;
    19      end f_read_consistency_tab;
    20    /
    Function created.
    mohamed@mhouri> select count(1) from t_read_consistency;
      COUNT(1)                                                                     
          1000                                                                     
    mohamed@mhouri> select count(1) from (select * from table(f_read_consistency_tab));
      COUNT(1)                                                                     
            10                                                                     
    mohamed@mhouri> insert into t_read_consistency
      2            (id,vc)
      3          select id,vc
      4      from table(f_read_consistency_tab)
      5     ;
        from table(f_read_consistency_tab)
    ERROR at line 4:
    ORA-04091: table MOHAMED.T_READ_CONSISTENCY is mutating, trigger/function may
    not see it
    ORA-06512: at "MOHAMED.F_READ_CONSISTENCY_TAB", line 7 In addition, one of the posters spotted out very judiciously that if we slightly change the definition of the table t_read_consistency in 11g, strangely the insert/select will work correctly in this data base as shown below:
    ohamed@mhouri> drop table tr_read_consistency;
    Table dropped.
    mohamed@mhouri> create table tr_read_consistency
      2      as select rownum rn,
      3                trs.*
      4      from
      5         t_read_consistency trs;
    Table created.
    mohamed@mhouri> insert into tr_read_consistency
      2                 (rn, id,vc)
      3              select rownum, id,vc
      4           from table(f_read_consistency_tab);
    10 rows created.So is this a regression? or a corrected bug during upgrade?
    Thanks in advance
    Mohamed Houri

    I just followed the doc links provided by Tubby, which have 100% Correct answer. See below :
    SQL> select * from v$version;
    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> show user;
    USER is "SCOTT"
    SQL> create type t_read_cs as object (id number,vc varchar2(15));
      2  /
    Type created.
    SQL> create type t_read_cs_tab  as table of t_read_cs;
      2  /
    Type created.
    SQL> create table t_read_consistency (id number, vc varchar2(15), primary key (id));
    Table created.
    SQL> create or replace function f_read_consistency_tab
      2  return t_read_cs_tab
      3  as
      4  lc_t_read_cs_tab t_read_cs_tab := t_read_cs_tab();
      5  j  binary_integer := 0;
      6  begin
      7  for x in (select
      8  id,
      9  vc
    10  from  t_read_consistency trs
    11  where trs.id <= 10
    12  ) loop
    13  j := j +1;
    14  lc_t_read_cs_tab.extend;
    15  lc_t_read_cs_tab(j) := t_read_cs(x.id, x.vc);
    16  end loop;
    17  RETURN lc_t_read_cs_tab;
    18  end f_read_consistency_tab;
    19  /
    Function created.
    SQL> insert into
      2  t_read_consistency
      3  select
      4  rownum id,
      5  rpad('a',15,'a')
      6  from
      7  dual
      8  connect by
      9  level<=1000;
    1000 rows created.
    SQL> select count(1) from t_read_consistency;
      COUNT(1)
          1000
    SQL> select count(1) from (select * from table(f_read_consistency_tab));
      COUNT(1)
            10
    SQL> insert into t_read_consistency
      2  (id,vc)
      3  select id,vc
      4  from table(f_read_consistency_tab);
    from table(f_read_consistency_tab)
    ERROR at line 4:
    ORA-04091: table SCOTT.T_READ_CONSISTENCY is mutating, trigger/function may not see it
    ORA-06512: at "SCOTT.F_READ_CONSISTENCY_TAB", line 7
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function f_read_consistency_tab
      2  return t_read_cs_tab
      3  as
      4  lc_t_read_cs_tab t_read_cs_tab := t_read_cs_tab();
      5  j  binary_integer := 0;
      6  PRAGMA AUTONOMOUS_TRANSACTION; <--- This works as documented in 11.2.0.1
      7  begin
      8  for x in (select
      9  id,
    10  vc
    11  from  t_read_consistency trs
    12  where trs.id <= 10
    13  ) loop
    14  j := j +1;
    15  lc_t_read_cs_tab.extend;
    16  lc_t_read_cs_tab(j) := t_read_cs(x.id, x.vc);
    17  end loop;
    18  RETURN lc_t_read_cs_tab;
    19* end f_read_consistency_tab;
    SQL> /
    Function created.
    SQL> insert into t_read_consistency
      2  (id,vc)
      3  select id,vc
      4  from table(f_read_consistency_tab);
    insert into t_read_consistency
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.SYS_C0011307) violated
    SQL> drop table t_read_consistency purge;
    Table dropped.
    SQL> create table t_read_consistency (id number, vc varchar2(15));
    Table created.
    SQL> insert into
      2  t_read_consistency
      3  select
      4  rownum id,
      5  rpad('a',15,'a')
      6  from
      7  dual
      8  connect by
      9  level<=1000;
    1000 rows created.
    SQL> commit;
    Commit complete.
    SQL> insert into t_read_consistency
      2  (id,vc)
      3  select id,vc
      4  from table(f_read_consistency_tab);
    10 rows created.
    SQL> commit;
    Commit complete.
    SQL>So, you have to add only PRAGMA AUTONOMOUS_TRANSACTION; before begin in your function code to avoid ORA-04091 in 11.2.0.1
    But, All thanks to Tubby who pointed us to the correct documentation link.
    Regards
    Girish Sharma

  • Log miner doesn't show all transactions on a table

    I'm playing a little with log miner on oracle 11gR2 on a 32bit CentOS Linux install, but it looks like it's not showing me all DML on my test table. Am I doing something wrong?
    Hi, there's my test case:
    - Session #1, create table and insert first row:
    SQL> create table stolf.test_table (
    col1 number,
    col2 varchar(10),
    col3 varchar(10),
    col4 varchar(10));
    2 3 4 5
    Table created.
    SQL> insert into stolf.test_table (col1, col2, col3, col4) values ( 0, 20100305, 0, 0);
    1 row created.
    SQL> commit;
    SQL> select t.ora_rowscn, t.* from stolf.test_table t;
    ORA_ROWSCN COL1 COL2 COL3 COL4
    1363624 0 20100305 0 0
    - Execute shell script to insert a thousand lines into table:
    for i in `seq 1 1000`; do
    sqlplus -S stolf/<passwd><<-EOF
    insert into stolf.test_table (col1, col2, col3, col4) values ( $ , 20100429, ${i}, ${i} );
    commit;
    EOF
    done
    - Session #1, switch logfiles:
    SQL> alter system switch logfile;
    System altered.
    SQL> alter system switch logfile;
    System altered.
    SQL> alter system switch logfile;
    System altered.+
    - Session #2, start logminer with continuous_mine on, startscn = first row ora_rowscn, endscn=right now. The select on v$logmnr_contents should return at least a thousand rows, but it returns three rows instead :
    BEGIN
    SYS.DBMS_LOGMNR.START_LOGMNR(STARTSCN=>1363624, ENDSCN=>timestamp_to_scn(sysdate), OPTIONS => sys.DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + sys.DBMS_LOGMNR.COMMITTED_DATA_ONLY + SYS.DBMS_LOGMNR.CONTINUOUS_MINE);
    END;
    SQL> select SCN, SQL_REDO, SQL_UNDO FROM V$LOGMNR_CONTENTS where SQL_REDO IS NOT NULL AND seg_owner = 'STOLF';
    SCN
    SQL_REDO
    SQL_UNDO
    1365941
    insert into "STOLF"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('378','20100429','378','378');
    delete from "STOLF"."TEST_TABLE" where "COL1" = '378' and "COL2" = '20100429' and "COL3" = '378' and "COL4" = '378' and ROWID = 'AAASOHAAEAAAATfAAB';
    1367335
    insert into "STOLF"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('608','20100429','608','608');
    delete from "STOLF"."TEST_TABLE" where "COL1" = '608' and "COL2" = '20100429' and "COL3" = '608' and "COL4" = '608' and ROWID = 'AAASOHAAEAAAATfAAm';
    1368832
    insert into "STOLF"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('849','20100429','849','849');
    delete from "STOLF"."TEST_TABLE" where "COL1" = '849' and "COL2" = '20100429' and "COL3" = '849' and "COL4" = '849' and ROWID = 'AAASOHAAEAAAATbAAA';+

    Enable supplemental logging.
    Please see below,
    SQL> shut immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount;
    ORACLE instance started.
    Total System Global Area  422670336 bytes
    Fixed Size                  1300352 bytes
    Variable Size             306186368 bytes
    Database Buffers          109051904 bytes
    Redo Buffers                6131712 bytes
    alter databsDatabase mounted.
    SQL>
      2
    SQL> alter database archivelog;
    Database altered.
    SQL> alter database open;
    Database altered.
    SQL> alter system checkpoint;
    System altered.
    SQL> drop table test_Table purge;
    Table dropped.
    SQL> create table test_table(
      2  col1 number,
    col2 varchar(10),
    col3 varchar(10),
    col4 varchar(10));  3    4    5
    Table created.
    SQL> insert into test_table (col1, col2, col3, col4) values ( 0, 20100305, 0, 0);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select t.ora_rowscn, t.* from test_table t;
    ORA_ROWSCN       COL1 COL2       COL3       COL4
       1132572          0 20100305   0          0
    SQL> for i in 1..1000 loop
    SP2-0734: unknown command beginning "for i in 1..." - rest of line ignored.
    SQL> begin
      2  for i in 1..1000 loop
      3  insert into test_table values(i,20100429,i,i);
      4  end loop; commit;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> alter system switch logfile;
    System altered.
    SQL> /
    SQL> select * from V$version;
    BANNER
    --------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for Linux: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - ProductionIn the second session,
    SQL> l
      1  select SCN, SQL_REDO, SQL_UNDO FROM V$LOGMNR_CONTENTS where SQL_REDO IS NOT NULL
      2* and seg_owner='SYS' and table_name='TEST_TABLE'
    --------------------------------------------------------------------------------insert into "SYS"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('2','20100429','2','2');
    delete from "SYS"."TEST_TABLE" where "COL1" = '2' and "COL2" = '20100429' and "COL3" = '2' and "COL4" = '2' and ROWID = 'AAASPKAABAAAVpSAAC';
       1132607
    insert into "SYS"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('3','2010042
           SCN
    SQL_REDO
    --------------------------------------------------------------------------------SQL_UNDO
    --------------------------------------------------------------------------------9','3','3');
    delete from "SYS"."TEST_TABLE" where "COL1" = '3' and "COL2" = '20100429' and "COL3" = '3' and "COL4" = '3' and ROWID = 'AAASPKAABAAAVpSAAD';
       1132607
    insert into "SYS"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('4','20100429','4','4');
    <<trimming the output>>
    --------------------------------------------------------------------------------429','997','997');
    delete from "SYS"."TEST_TABLE" where "COL1" = '997' and "COL2" = '20100429' and
    "COL3" = '997' and "COL4" = '997' and ROWID = 'AAASPKAABAAAVpVACU';
       1132607
    insert into "SYS"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('998','20100429','998','998');
           SCN
    SQL_REDO
    --------------------------------------------------------------------------------SQL_UNDO
    --------------------------------------------------------------------------------delete from "SYS"."TEST_TABLE" where "COL1" = '998' and "COL2" = '20100429' and
    "COL3" = '998' and "COL4" = '998' and ROWID = 'AAASPKAABAAAVpVACV';
       1132607
    insert into "SYS"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('999','20100429','999','999');
    delete from "SYS"."TEST_TABLE" where "COL1" = '999' and "COL2" = '20100429' and
           SCN
    SQL_REDO
    --------------------------------------------------------------------------------SQL_UNDO
    --------------------------------------------------------------------------------"COL3" = '999' and "COL4" = '999' and ROWID = 'AAASPKAABAAAVpVACW';
       1132607
    insert into "SYS"."TEST_TABLE"("COL1","COL2","COL3","COL4") values ('1000','20100429','1000','1000');
    delete from "SYS"."TEST_TABLE" where "COL1" = '1000' and "COL2" = '20100429' and "COL3" = '1000' and "COL4" = '1000' and ROWID = 'AAASPKAABAAAVpVACX';
           SCN
    SQL_REDO
    --------------------------------------------------------------------------------SQL_UNDO
    1000 rows selected.
    SQL>HTH
    Aman....

  • How to insert 20 records  only in one table

    hi to all,
    i want insert 20 records only in a table,but suppose i want to enter 21th record it will not inserted .
    suppose delete one record then insert, it will insert.
    but always count(*) is not greater than 20.
    is there any solution for that,
    pls help me

    Yes there is a solution for that using a materialied view:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    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
    SQL> drop table t purge;
    Table dropped.
    SQL> drop materialized view t_mv;
    Materialized view dropped.
    SQL> create table t (
      2  x integer,
      3  y varchar2(30)
      4  );
    Table created.
    SQL> CREATE MATERIALIZED VIEW LOG on t
      2  WITH ROWID (x, y)
      3  including new values;
    Materialized view log created.
    SQL> CREATE MATERIALIZED VIEW t_mv
      2  REFRESH FAST ON COMMIT AS
      3  SELECT count(*) cnt
      4  FROM t;
    Materialized view created.
    SQL> alter table t_mv ADD CONSTRAINT chk check(cnt<=20);
    Table altered.
    SQL> insert into t select object_id, object_name from all_objects where rownum <
    21;
    20 rows created.
    SQL> commit;
    Commit complete.
    SQL> insert into t values(21,'KO');
    1 row created.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-02290: check constraint (TEST.CHK) violated
    SQL>
    SQL> select count(*) from t;
      COUNT(*)
            20
    SQL>Not sure that trigger based solution works due to multi versioning read consistency.

  • How do i count number of table being used in a view

    Hi All,
    I will be really thankful if anyone please let me know about the count of number of tables being used in a view. I am using Oracle 10g Release 2 on HP-UX(11.31).
    In actual I have to find views in my database with more than 5 table in join.
    Thank you
    Gursimran

    Try :
    select count(*) from dba_dependencies
    where name ='<view name>'
    and owner = '<view owner>'
    and referenced_type= 'TABLE';Example:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    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
    SQL> show user;
    USER is "HR"
    SQL>
    SQL> drop table t1 purge;
    Table dropped.
    SQL> drop table t2 purge;
    Table dropped.
    SQL> drop table t3 purge;
    Table dropped.
    SQL> drop view v;
    View dropped.
    SQL>
    SQL> create table t1(x int);
    Table created.
    SQL> create table t2(y int);
    Table created.
    SQL> create table t3(z int);
    Table created.
    SQL> create view v as select x,y,z from t1,t2,t3;
    View created.
    SQL>
    SQL> connect / as sysdba
    ConnectÚ.
    SQL> alter session set nls_language=english;
    Session altered.
    SQL>
    SQL> select count(*) from dba_dependencies
      2  where name ='V'
      3  and owner = 'HR'
      4  and referenced_type= 'TABLE';
      COUNT(*)
             3
    SQL>Edited by: P. Forstmann on 26 juil. 2010 17:45

Maybe you are looking for

  • How to find out the listeners on a Queue

    Hi, We are using publish/subscribe method to send messages. Given a queue name, is there any way to find out the number of sessions listening on this Queue. that is if there are two servers subscribed to listen messages from a Queue, is there a way t

  • MM interview questions

    Hi Experts,   Can you give answers for the following questions. Points will be awarded. Need it urgently. General/Organizational Elements/Master Data 1. What is meant by a client in the SAP R/3 System? A: Commercial and organizational unit with in R/

  • Preloading several files, showing one "% loaded" value

    Hello everyone. For this website I'm developing I need to preload several files (images, xml, css and the main .swf). I have a preloader and I want it to show the total % loaded of the sum of all those files. From what I've learned so far, I need a P

  • Background step in workflow remains in process: Workflow gets stuck up

    Hi Gurus, I have custom workflow for organization management. The workflow takes information from e-forms(notifications) and updates the infotypes. The step which updates infotypes is run as background step.However in some cases the workflow gets stu

  • Edit Home Screen .....  Dismiss button is stuck on my screen

    I just upgraded my 3G phone to 2.1. Since I have upgraded, I have not been able to use my phone at all. I have a window displayed on my phone. Edit Home Screen To rearrange icons, touch and hold any icon until it starts to wiggle, then drag icons to