Primary key and WHO columns on EO

We are trying to create a EO based on a database view. We do not have primary key and standard OA WHO columns but the OA framework is forcing us the have these columns. How do we go about this issue? Any suggestion will be appreciated.

Oracle Apps mandates that you should have the Audit columns in the Applications tables.
So you must have the 5 columns defined.
I have created new tables for my application and need to populate them whenever user creates or modifies any row
Jdeveloper/BC4J handles direct updates/inserts through default EO implementation, it would insert/update/delete from the base table via the EO, what is your qeustion then ? do you want to know how to perform DMLs in OA or something else ?
Thanks
Tapash

Similar Messages

  • Primary key and Foreign key on same column

    Hi, I am able to create below tables , primary and foreign keys as below.
    But Is this valid design? Can I define a column (ckey2 in table "child") as
    primary key and as well as foreign key?
    CREATE TABLE parent (
    col1 NUMBER,
    col2 NUMBER
    CREATE TABLE child (
    ckey1 NUMBER,
    ckey2 NUMBER,
    ckey3 NUMBER
    alter table parent add constraint parent_pk primary key( col1 );
    alter table child add constraint child_pk primary key( ckey2 );
    alter table child add constraint child_fk foreign key( ckey2 ) references parent( col1);
    Thanks.

    Can I define a column (ckey2 in table "child") as primary key and as well as foreign key?You mean you want to define a one-to-one relationship between parent and child tables.. why would you want to do that ? You might as well merge the 2 tables into one.

  • Difference between primary key and primary index

    Dear All,
             Hi... .Could you pls tell me the difference between primary key and primary index.
    Thanks...

    Hi,
    Primary Key : It is one which makes an entry of the field unique.No two distinct rows in a table can have the same value (or combination of values) in those columns.
    Eg: first entry is 111, if you again enter value 111 , it doesnot allow 111 again. similarly for the strings or characters or numc etc. Remember that for char or numc or string 'NAME' is not equal to 'name'.
    Primary Index: this is related to the performance .A database index is a data structure that improves the speed of operations in a table. Indices can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records. The disk space required to store the index is typically less than the storage of the table (since indices usually contain only the key-fields according to which the table is to be arranged, and excludes all the other details in the table), yielding the possibility to store indices into memory from tables that would not fit into it. In a relational database an index is a copy of part of a table. Some databases extend the power of indexing by allowing indices to be created on functions or expressions. For example, an index could be created on upper(last_name), which would only store the uppercase versions of the last_name field in the index.
    In a database , we may have a large number of records. At the time of retrieving data from the database based on a condition , it is a burden to the db server. so whenever we create a primary key , a primary index is automatically created by the system.
    If you want to maintain indices on other fields which are frequently used in where condition then you can create secondary indices.
    Reward points if helpful.
    Thanks,
    Sirisha..

  • Is their a difference between primary key and unique key with not null valu

    What is the difference in having a column as primary key and having unique key with not null for the column.
    vinodh

    SBH wrote:
    For quick review, below is the link
    http://www.dba-oracle.com/data_warehouse/clustered_index.htm
    You appear to have stumbled on a site that is a mine of disinformation about Oracle.
    >
    It would be helpful, if you explain it too..thnx !!
    The site is wrong and makes up its own terminology as it goes along.
    If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
    There is no create clustered index in Oracle.
    - Clustering factor affects the efficiency of an index.
    - There can be clustered tables that you can create indexes on.
    - An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all.

  • Primary keys and store generated pattern

    Hi,
    in my database first application (Firebird), the primary keys are not set to identity by default !
    any ideas why this ?

    Solved !
    put #PK_GEN# as comment for your primary key and now EF import primary keys columns as identity like expeted :)
    btw, fb 3.0 and up support identity columns .

  • Primary keys and constraints are gone....

    Hi Experts,
    I had a schema SchemaD with all primary keys and referential constraints. And i am a TOAD user. I had one more source schema SchemaS.
    In my destination schema all the tables has 2 extra columns for data warehouse purpose.
    I disabled all the constraints and i used toad utility "Copy Data to Another Schema" and i selected all the tables from Source SchemaS.
    After the completion of data copy i tried to enable all the constraints in SchemaD. But i found that there are no primary keys and referential integrates in that schema.
    Please help me in this issue.
    Thanks...
    Ray

    Check in the views "DBA_CONSTRAINTS" or ALL_CONSTRAINTS" with the condition owner='your_schema_name'
    If you are using toad to view the constraints, chances are high that there is a filter in the toad view and it is filtering the constraints...
    Edited by: Suchit on Feb 25, 2009 5:19 PM
    Edited by: Suchit on Feb 25, 2009 5:20 PM

  • Primary keys and foreign keys

    Hi,
    is there a script available for changing the value of a primary key which automaticly
    detect all foreigs keys refering to this primary key and change them as well?
    William Oorschot

    I don't have the script now. but you can make a procedure of ur own.
    using a join on user_constraints, and user_cons_columns you can find out all the columns in all the tables which are referencing the particular primary key. once you have the table and the referencing columns, you can change the value of those columns with the new value.
    you'll have to call this procedure from a before row level trigger.
    HTH
    Naveen

  • Primary Key With Four Column ,How to use that Column As Primary Key In Form

    Dear All,
    i have create composite Key as primary Key With Four Column .
    How can i use these column in Form With Report Page.
    How can i use these four Column as primary Key to Edit Record .
    How can i do this.
    Thanks
    Vedant

    wrap a view around your table with this bogus primary key. Use an instead of trigger to handle the inserts and updates. And then look at using surrogate keys to resolve these bad design issues...
    5 out of 4 people don't understand fractions.
    Thank you,
    Tony Miller
    Webster, TX

  • Update a primary key and Fk

    Hello
    I have to update a primary key (PK) which is referenced by many foreign keys (FK).
    The primary key columns cannot be updated as this would orphan the dependant tables,
    and the dependant tables cannot be updated prior to the parent table as this would also make them orphans.
    I think this problem was solved by disabling the foreign key constraints or deleting the original records and recreating them.
    Since neither of these solutions is particularly satisfactory for me I read about 'deferred constraints'.
    My question is:
    Can I use(modify to) 'INITIALLY DEFERRED' keyword on constraints's table already created with The default, INITIALLY IMMEDIATE ,
    that is, update my primary key and foreign keys, and then re-set to
    'INITIALLY IMMEDIATE'? Or another trick exists ?
    Thanks in advance for your attention

    It is very popular the idea that the updates on primary key columns are a very bad thing.
    Oracle supports this idea and that's why they don't give the "on update cascade" clause on foreign keys.
    So in this case I suggest you to define a master table like this.
    create table master_table (
         key_id number primary key,
         your_primary_key varchar2 not null unique
    /Then you must use that key_id column as foreign key in place of your original primary key. In this way don't even need to update referencing rows when updating the original primary key because the foreign key value doesn't change and everything is always fine as before.
    So instead to lose time implementing some strange sort of cascade triggers plain to do something like this on your schema.
    insert into master_table (id_key,primary_key) (
         select rownum,primary_key
         from your_main_table
    alter table your_main_table add (
         id_key number,
    update your_main_table a
    set id_key = (
              select b.id_key
              from master_table
              where b.primary_key=a.primary_key
         Drops foreign keys
    alter table your_main_table drop primary key cascade
    alter table your_main_table add constraint pk
         primary key(id_key)
    alter table your_main_table add constraint fk
         foreign key(id_key) references master_table
    alter table your_main_table drop (
         your_primary_key
    alter table a_referencing_table add (
         id_key number,
    update a_referencing_table a
    set id_key = (
              select b.id_key
              from master_table
              where b.primary_key=a.primary_key
    alter table a_referencing_table add constraint fk_2
         foreign key(id_key) references master_table
    alter table a_referencing_table drop (
         your_primary_key
    /If you have many objects referencing those tables I suggest you to rename the tables and to create views with the original name of the renamed tables that show data as it was before with a join on master_table. in this way you don't need to change the code of the application referencing them but you just need to recompile invalidated objects.
    Bye Alessandro

  • Assigning primary key and index for a table

    I have a database consisting of only one table with 10 million rows which mostly looks like this:
    RECORDDATE                     ID     CLASS     VALUE
    24-JAN-12 10.52.47.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     10     156
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     10     156
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     6     38
    24-JAN-12 10.53.05.000000 AM     253     16     197
    24-JAN-12 10.53.06.000000 AM     98     10     150
    24-JAN-12 10.53.06.000000 AM     98     0     0
    24-JAN-12 10.53.06.000000 AM     98     4     0
    24-JAN-12 10.53.06.000000 AM     98     11     33As you can see there are several entries that look exactly the same. Currently, I don't have primary key or index for any column and have a lot of performance issues. For example this query takes more than 10 seconds to run:
    select distinct      ID
    from      scdatabase4
    where ID < 253
    order by 1Since database is not my primary job and have no background of it, I'm really confused about what to do to fix my issues. Could someone please help me in assigning primary key and index if you agree that this is the problem?!

    Execute the query below to help decide what column to index:
    SELECT COLUMN_NAME, NUM_DISTINCT, NUM_NULLS, NUM_BUCKETS, DENSITY
    FROM DBA_TAB_COL_STATISTICS
    WHERE TABLE_NAME = 'your_table_name'
    ORDER BY COLUMN_NAME;
    The important columns are:
    1) NUM_DISTINCTS: Indicates the number of distinct values. If this number is very low for a column, it indicates that this column is not a very good candidate for a B-Tree index.
    2) NUM_NULL: Indicates the number of null values for each column. A column with few null values is a good candidate for a index
    But be aware, this is not a rule, it's just a method to help decide which column will have the most benefit of index creation.

  • How do I use Primary Key and RowID in Materialized View Logs and MVs

    How do I use Primary Key and RowID in Materialized View Logs and Materialized Views????
    I don’t understand in the Materalized View Logs the diference between Primary Key and RowID. Besides, I could choose both Primary Key and RowID.
    When I have to use RowID?? Why?? And Primary Key??? And both, Primary Key and RowID????
    Thank you very much!

    Yes, I have already read it...
    But for example I don’t Understand:
    This is the example 8-1
    CREATE MATERIALIZED VIEW LOG ON products
    WITH SEQUENCE, ROWID
    (prod_id, prod_name, prod_desc, prod_subcategory, prod_subcat_desc, prod_
    category, prod_cat_desc, prod_weight_class, prod_unit_of_measure, prod_pack_
    size, supplier_id, prod_status, prod_list_price, prod_min_price)
    INCLUDING NEW VALUES;
    But if I create a Materialized View with TOAD if I choose a KEY field I receive the error:
    ORA-12026: invalid filter column detected
    Then I have to take out the Key (in the above example prod_id)
    And then the script is
    CREATE MATERIALIZED VIEW LOG ON products
    WITH ROWID, SEQUENCE, PRIMARY KEY!!!!!!!!!!!!!!!!!!!!
    (prod_id, prod_name, prod_desc, prod_subcategory, prod_subcat_desc, prod_
    category, prod_cat_desc, prod_weight_class, prod_unit_of_measure, prod_pack_
    size, supplier_id, prod_status, prod_list_price, prod_min_price)
    INCLUDING NEW VALUES;
    I have PRIMARY KEY in the definition (I don’t choose it) and I don’t have the prod_id field
    Why is it????
    Note: If I execute the script to create the MV Log manually the PRIMARY KEY option NO IS in the script and the prod_id field either is in the script.
    And on the other hand,
    What is this:
    CREATE MATERIALIZED VIEW LOG ON sales
    WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON times
    WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON customers
    WITH ROWID;
    These MATERIALIZED VIEW LOG contain any fields????
    Or it contain the primary key fields of this tables (sales, times and customers)??? Then, Why is it ROWID instead of PRIMARY KEY????
    Thanks!

  • No matching unique or primary key for this column-list --error

    CREATE TABLE CUSTOMER(CUS_NUM NUMBER(10) PRIMARY KEY,CUS_NAME VARCHAR2(50),ADDRESS VARCHAR2(50));
    CREATE TABLE ITEM(ITEM_NUM NUMBER(10),ITEM_DESC VARCHAR2(50),TYPE VARCHAR2(50),ITEM_STATUS VARCHAR2(50),
    CONSTRAINT PK_ITEM PRIMARY KEY(ITEM_NUM,TYPE));
    CREATE TABLE ITEM_TYPE(TYPE VARCHAR2(50) PRIMARY KEY,TYPE_NAME VARCHAR2(50),SKU VARCHAR2(50),RATING VARCHAR2(50));
    CREATE TABLE ORDERS(ORDER_NUMBER NUMBER(10),CUS_NUM NUMBER(10),ITEM_NUM NUMBER(10),ORDER_POINT VARCHAR2(50),DISPATCH_POINT VARCHAR2(50),
    PRIORITY VARCHAR2(50),ORDER_STATUS VARCHAR2(50),
    CONSTRAINT PK_ORDERS PRIMARY KEY(ORDER_NUMBER,ITEM_NUM),
    CONSTRAINT FK1_ORDERS FOREIGN KEY (CUS_NUM) REFERENCES CUSTOMER(CUS_NUM),
    CONSTRAINT FK2_ORDERS FOREIGN KEY (ITEM_NUM) REFERENCES ITEM(ITEM_NUM));
    Hi,friends i created tables as above when i creating 'ORDERS' table the error will fir as "ORA-02270: no matching unique or primary key for this column-list".
    can any body solve this issue.
    Cheers,
    Sudhir reddy.

    For your own sanity, you should learn to format your code, or use a tool to do it for you. For the sanity of the forum members, you should preserve that code using the \ tagsCREATE TABLE CUSTOMER
    CUS_NUM NUMBER(10) PRIMARY KEY,
    CUS_NAME VARCHAR2(50),
    ADDRESS VARCHAR2(50)
    CREATE TABLE ITEM
    ITEM_NUM NUMBER(10),
    ITEM_DESC VARCHAR2(50),
    TYPE VARCHAR2(50),
    TYPE is a reserved word.  Call it ITEM_TYPEITEM_STATUS VARCHAR2(50),
    CONSTRAINT PK_ITEM PRIMARY KEY(ITEM_NUM,TYPE)
    CREATE TABLE ITEM_TYPE
    TYPE VARCHAR2(50) PRIMARY KEY,
    again, with the reserved word.TYPE_NAME VARCHAR2(50),
    SKU VARCHAR2(50),
    RATING VARCHAR2(50)
    CREATE TABLE ORDERS
    ORDER_NUMBER NUMBER(10),
    be consistent.  NUM or NUMBER.  Pick one and stick with it.CUS_NUM NUMBER(10),
    ITEM_NUM NUMBER(10),
    ORDER_POINT VARCHAR2(50),
    DISPATCH_POINT VARCHAR2(50),
    PRIORITY VARCHAR2(50),
    ORDER_STATUS VARCHAR2(50),
    CONSTRAINT PK_ORDERS PRIMARY KEY(ORDER_NUMBER,ITEM_NUM),
    CONSTRAINT FK1_ORDERS FOREIGN KEY (CUS_NUM) REFERENCES CUSTOMER(CUS_NUM),
    CONSTRAINT FK2_ORDERS FOREIGN KEY (ITEM_NUM) REFERENCES ITEM(ITEM_NUM)

  • Primary key for an column consisting duplicates

    hi,
    ------->i have created a table and
    -------> i have a column consisting of 1000 records (but where i have duplicates)
    and now i want to create a primary key for the column
    how can i do it....

    Hi,
    You can find records which contains duplicate values for the table column using Oracle exceptions table. Please see a small demonstration:-
    SQL> create table test1(id number);
    Table created.
    SQL> insert into test1 values(&id);
    Enter value for id: 1
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(1)
    1 row created.
    SQL> /
    Enter value for id: 2
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(2)
    1 row created.
    SQL> /
    Enter value for id: 3
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(3)
    1 row created.
    SQL> /
    Enter value for id: 1
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(1)
    1 row created.
    SQL> /
    Enter value for id: 3
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(3)
    1 row created.
    SQL> /
    Enter value for id: 4
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(4)
    1 row created.
    SQL> /
    Enter value for id: 5
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(5)
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter table test1 add constraint id_pk primary key(id);
    alter table test1 add constraint id_pk primary key(id)
    ERROR at line 1:
    ORA-02437: cannot validate (SYS.ID_PK) - primary key violated
    SQL> alter table test1 add constraint id_pk primary key(id) exceptions into exceptions;
    alter table test1 add constraint id_pk primary key(id) exceptions into exceptions
    ERROR at line 1:
    ORA-02445: Exceptions table not found
    SQL> @?/rdbms/admin/utlexcpt
    Table created.
    SQL> alter table test1 add constraint id_pk primary key(id) exceptions into exceptions;
    alter table test1 add constraint id_pk primary key(id) exceptions into exceptions
    ERROR at line 1:
    ORA-02437: cannot validate (SYS.ID_PK) - primary key violated
    SQL> desc exceptions
    Name Null? Type
    ROW_ID ROWID
    OWNER VARCHAR2(30)
    TABLE_NAME VARCHAR2(30)
    CONSTRAINT VARCHAR2(30)
    SQL> select * from exceptions;
    ROW_ID OWNER TABLE_NAME CONSTRAINT
    AAAc95AABAAA9EpAAD SYS TEST1 ID_PK
    AAAc95AABAAA9EpAAA SYS TEST1 ID_PK
    AAAc95AABAAA9EpAAE SYS TEST1 ID_PK
    AAAc95AABAAA9EpAAC SYS TEST1 ID_PK
    SQL> select * from test1 where rowid in(select row_id from exceptions);
    ID
    3
    1
    1
    3
    Thanks
    Edited by: rarain on May 28, 2013 12:10 PM

  • Diff b/w primary key and unique key?

    what is the diff b/w primary key and unique key?

    Hi,
    With respect to functionality both are same.
    But in ABAP we only have Primary key for the Database tables declared in the Data Dictionary.
    Unique is generally is the term used with declaring key's for internal tables.
    Both primary and Unique keys can identify one record of a table.
    Regards,
    Sesh

  • Access path difference between Primary Key and Unique Index

    Hi All,
    Is there any specific way the oracle optimizer treats Primary key and Unique index differently?
    Oracle Version
    SQL> select * from v$version;
    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 IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> Sample test data for Normal Index
    SQL> create table t_test_tab(col1 number, col2 number, col3 varchar2(12));
    Table created.
    SQL> create sequence seq_t_test_tab start with 1 increment by 1 ;
    Sequence created.
    SQL>  insert into t_test_tab select seq_t_test_tab.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(USER_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
            259  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> create index idx_t_test_tab on t_test_tab(col1);
    Index created.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> Sample test data when using Primary Key
    SQL> create table t_test_tab1(col1 number, col2 number, col3 varchar2(12));
    Table created.
    SQL> create sequence seq_t_test_tab1 start with 1 increment by 1 ;
    Sequence created.
    SQL> insert into t_test_tab1 select seq_t_test_tab1.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB1',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab1;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1727568366
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |             | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB1 | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> alter table t_test_tab1 add constraint pk_t_test_tab1 primary key (col1);
    Table altered.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB1',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab1;
    99999 rows selected.
    Execution Plan
    Plan hash value: 2995826579
    | Id  | Operation            | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                | 99999 |   488K|    59   (2)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| PK_T_TEST_TAB1 | 99999 |   488K|    59   (2)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6867  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> If you see here the even though statistics were gathered,
         * In the 1st table T_TEST_TAB, the table is still using FULL table access after creation of index.
         * And in the 2nd table T_TEST_TAB1, table is using PRIMARY KEY as expected.
    Any comments ??
    Regards,
    BPat

    Thanks.
    Yes, ignored the NOT NULL part.Did a test and now it is working as expected
    SQL>  create table t_test_tab(col1 number not null, col2 number, col3 varchar2(12));
    Table created.
    SQL>
    create sequence seq_t_test_tab start with 1 increment by 1 ;SQL>
    Sequence created.
    SQL> insert into t_test_tab select seq_t_test_tab.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL>  exec dbms_stats.gather_table_stats('GREP_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL>  set autotrace traceonly
    SQL>  select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6912  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL>  create index idx_t_test_tab on t_test_tab(col1);
    Index created.
    SQL>  exec dbms_stats.gather_table_stats('GREP_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL>  select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 4115006285
    | Id  | Operation            | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                | 99999 |   488K|    63   (2)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| IDX_T_TEST_TAB | 99999 |   488K|    63   (2)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6881  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL>

Maybe you are looking for