Primary keys in Tables Oracle EBS Standard

Hello! I was checking a few standard EBS tables and I just found it odd that there is no primary keys in the columns which (I think) should be the primary key:

an exaple:

AP_INVOICE_LINES_ALL DESC;

Column nameIDPKNull value?Data typeBy defaultHistogram
INVOICE_ID1NNUMBER (15)Yes
LINE_NUMBER2NNUMBERYes
LINE_TYPE_LOOKUP_CODE3NVARCHAR2 (25 bytes)Yes
REQUESTER_ID4THERENUMBER (15)Yes
DESCRIPTION5THEREVARCHAR2 (240 bytes)Yes
LINE_SOURCE6THEREVARCHAR2 (30 bytes)Yes
ORG_ID7THERENUMBER (15)NULL VALUEYes
LINE_GROUP_NUMBER8THERENUMBERYes
INVENTORY_ITEM_ID9THERENUMBERYes
ITEM_DESCRIPTION10THEREVARCHAR2 (240 bytes)Yes
SERIAL_NUMBER11THEREVARCHAR2 (35 bytes)Yes
MANUFACTURER12THEREVARCHAR2 (30 bytes)Yes

GL_CODE_COMBINATIONS DESC;

Column nameIDPKNull value?Data typeBy defaultHistogram
CODE_COMBINATION_ID1NNUMBER (15)Yes
LAST_UPDATE_DATE2NDATEYes
LAST_UPDATED_BY3NNUMBERYes
CHART_OF_ACCOUNTS_ID4NNUMBER (15)Yes
DETAIL_POSTING_ALLOWED_FLAG5NVARCHAR2 (1 byte)Yes
DETAIL_BUDGETING_ALLOWED_FLAG6NVARCHAR2 (1 byte)Yes
ACCOUNT_TYPE7NVARCHAR2 (1 byte)Yes
ENABLED_FLAG8NVARCHAR2 (1 byte)Yes

I checked 11i and R12 versions of our Tables to EBS, but both contain primary keys.

Is this normal or just tell set primary keys?

Please notify.

Thank you!

PS.* I'm trying to settle our scripts and he is still running a full table scan, because it doesn't have a primary key.

Hello

This is the standard installation done by oracle at time of installation of EBS in your organization therefore does not necessarily create a new primary key or an index

on the table.

The key primary is a combination of unique key constraint not null, and if you look at the script or the definition of the table, you will get the already

Ed configuration not null not forced and a unique index on some of the columns required by oracle.

Tags: Oracle Applications

Similar Questions

  • ORA-02266: permit to unique/primary keys in table referenced by foreign keys

    Hello
    I'm trying to delete data from a table by dropping a partition. I've identified all the child tables by running the following command.

    Select "select count (*) from ' |" table_name |' where employee_id = 100; »
    of dba_constraints
    where constraint_type = 'R '.
    and r_constraint_name in
    (select constraint_name from dba_constraints
    where constraint_type in ('P', 'U') and table_name =' EMPLOYEE);


    "SELECTCOUNT (*) OF | TABLE_NAME | "WHEREEMPLOYEE_ID_ID = 100; »
    -----------------------------------------------------------------------------------------------
    Select count (*) in the PT_ORDERS where employee_id = 100;
    Select count (*) in the PT_DEP where employee_id = 100;
    Select count (*) in the PT_SKILLSET where employee_id = 100;

    I dropped the score for number 100 in all child tables. The count (*) select returns 0 rows for each of the foregoing.

    When I try to run the command on the EMPLOYEE table, below I get ' ORA-02266: unique/primary keys in table referenced by foreign keys enabled.

    Drop partition ALTER table EMPLOYEE EMP_ID_100;

    I don't see why I am unable to give up this partition now because it is data child present in any of the referenced tables. Any suggestions or help on this would be greatly appreciated.

    Thank you.

    RGS,
    Rob

    You must first disable foreign key constraints and delete the partition. Deletion of lines or a fall in childs partitions do not work in this case
    as you have the overall dependence:


    SQL > create table scott.t (x int primary key, int y)
    2 partition by (list (y)
    3 values p_1 (1) partition, partition values p_2 (2))
    4.

    Table created.

    SQL > create table scott.t_c (x int references scott.t (x), int y)
    2 partition by (list (y)
    3 values p_1 (1) partition, partition values p_2 (2))
    4.

    Table created.

    SQL > insert into scott.t values (1,1)
    3 N

    1 line of creation.

    SQL > insert into scott.t values (2,2)
    3 N

    1 line of creation.

    SQL > insert into scott.t_c values (1,1)
    3 N

    1 line of creation.

    SQL > insert into scott.t_c values (2,2)
    3 N

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > alter table scott.t_c drop partition p_2.

    Modified table.

    SQL > alter table scott.t drop partition p_2.
    ALTER table drop partition p_2 scott.t
    *
    ERROR on line 1:
    ORA-02266: permit to unique/primary keys in table referenced by foreign keys

    SQL > select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'P '.
    3 and table_name = 't';

    CONSTRAINT_NAME
    ------------------------------
    SYS_C0011058

    SQL > select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'R '.
    3 and r_constraint_name = "SYS_C0011058";

    CONSTRAINT_NAME
    ------------------------------
    SYS_C0011059

    SQL > alter the constraint to disable scott.t_c table SYS_C0011059;

    Modified table.

    SQL > alter table scott.t drop partition p_2.

    Modified table.

    SQL > alter table scott.t_c enable novalidate constraint SYS_C0011059;

    Modified table.

    I guess you should consider options such as partitioning Referencial (with some restrictions).

    Best wishes
    Dmitry.

  • ORA-02449: unique/primary keys in table referenced by foreign keys

    SQL > create table empinformation
    () 2
    primary key pk_empinformation number (6) 3 forced mobileno
    4 address varchar (100),
    5 salary number (10),
    6 personalid varchar (10) constraints fk_employees_section references employee (emp_id));

    Table created.


    SQL > drop table empinformation;

    ORA-02449: unique/primary keys in table referenced by foreign keys

    solution

    This error happens when the foreign key of a table is referenced by the primary key of the other table.

    If you want to remove the table had refernce key then, you must
    need to remove this table with the foreign key is referenced.

    or

    SQL > drop table EMPLOYEE CASCADE CONSTRAINTS;
    Deleted table.

    This will remove the table parent without droping the child table.

    Published by: Ritesh Singh October 3, 2011 14:04

  • I am trying to create a sequence to be used as a primary key in an Oracle table

    Hi guys

    I ODI version 10.3.5 and I'm trying to create a sequence that fills with row_id for a table. The schema is a database.
    And I want that this element will be the primary key of the table that is responsible to run the interface but I get questions.

    So please advise me.

    Hello

    Can you please provide the following details:
    1. What is the area of the execution of your sequence? Is it source, scene or target.
    2. what IKM you use (hopefully, you run the sequence in the staging or the target)?

    My understanding is when you check in not Null, all your lines going to the error table. So it gives no error.

    When you uncheck the not Null, it is in error because the database does not Null values in the primary key column.

    You can do the following to check if your sequence is working properly.
    Try to write an Insert Select query to DB and run it and see if it works properly.

    i.e.

    Insert (EMPL)
    EMPNO,
    ENAME,
    EMPLOYMENT,
    BISHOP.
    HIREDATE,
    SAL,
    COMM,
    DEPTNO
         
    )
    Select S_EMPNO. NEXTVAL,
    ENAME,
    EMPLOYMENT,
    BISHOP.
    HIREDATE,
    SAL,
    COMM,
    DEPTNO
         
    from EMP

    or if you can provide your query in this format, it will help find the question quickly. Please also indicate the KM.

  • Help with primary key in table

    Hello

    I created a table in Oracle and it filled with information, but I need a primary key (such as an AutoNumber in Access) to identify each record. How can I do this for an existing table?

    Thanks much for any help you can provide!

    Hello

    You can leave down the old sequence and then create a new, or same but make sure that the sequence must be referenced in the trigger to generate IDs.

    drop sequence ;

    Let me know if its works for you or not.

    concerning

    Published by: OrionNet on March 9, 2009 20:50

  • Primary key for tables

    Hi guys,.

    I had a simple order form when you add products.

    So I had 2 tables, ORDER (order_id, order_date) and ORDER_ITEMS (order_id, product_id, product_qty)

    My ORDER_ITEMS are added through tabular form
    select * from ORDER_ITEMS WHERE ORDER_iD = :P21_ORDER_ID;
    I can't create a 1 time order, as I create the ORDER first to get the primary key to add to ORDER_ITEM. I tried the Return key in point and placed the DML above the ApplyMRU process. But no luck.

    THE P21_ORDER_ID is display only save session state.

    Bit at a loss how to create both and to order and add its items in a single time instead of creating the order first then order items. Anyone know how I can accomplish this?

    Return key point seems to be the solution for this but I can't get it to work. Thank you very much.

    Take a look at your request, I changed the driver to the new process page, products and create an order which returns the primary key. Now you can create the initial product registration with in the process. do not disable the multirow process that always allows you to add or update records.

  • ADF: addition of the JSF error message: another user has modified the line containing oracle.jbo.Key [185 primary key].

    When you call the function DB. The function performs its operation, but shows an exception. In JDev 11.1.2.3

    And there is not another user. I'm testing alone.

    ADF: addition of the JSF error message: another user has modified the line containing oracle.jbo.Key [185 primary key].

    oracle.jbo.RowInconsistentException: Houston-25014: another user has modified the line containing oracle.jbo.Key [185 primary key].

    The problem is that the function db has a commit and my code also. However the db function called once in a case.

    Thanks a lot for your help.

  • What is the difference between primary key and unique indexes with forced not null?

    Primary key is = unique index + not null?

    The short answer is Yes.

    However, even if the primary key, applying both uniquness and not null, there is a notion of "special".

    You can only have one primary key in tables, but you can have multiple unique indexes and constraints not null.

    See: https://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:8743855576462

  • Add new ID/Primary Key column with custom ID generation

    I use Hibernate as ORM to interact with Oracle.

    This issue is no longer on the side of SQL to emulate the generator ID seqHiLo

    that we use to generate the primary key for tables, the column ID i.e.

    Now I want to add a new column to the ID of an already created table, and this table has data.

    I have a procedure to add the ID column in a table:

    For example:

    ALTER table TableName add (columnName NUMBER);

    Then create the sequence

    CREATE SEQUENCE SEQ_ID

    START WITH 1

    INCREMENT BY 1

    MAXVALUE 99999999

    MINVALUE 1

    NOCYCLE;

    and after that he use the UPDATE statement to insert some values into the column like this

    UPDATE tableName SET columnName is seq_test_id. NEXTVAL

    Here I intend to use hibernate_sequence, to be in harmony with the hibernation of generation mode the ID's

    The question is:

    UPDATE tableName SET columnName = hibernate_sequence. NEXTVAL, generates the ID in the order.

    However, I need identifiers according to the algorithm of seqHiLo.

    Is there a way to do this in pure SQL?

    In short, can we have a personalized way to generate IDS to use in the new column, rather than a sequential,

    as stated above?

    If you update every row of a session, it won't make any difference if you select from a sequence and use this value immediately (as in your example) or if you go through the algorithm of HiLo: be it you will end up with sequentially numbered lines without leaving space. Then after the update block of existing lines, you will need to create the sequence to be used by your Hibernate application with an initial value of your current value divided by the low value.

    If you really want to implement the algorithm of HiLo for the bulk loading, you can of course do so. But it is not necessary: the effect will be the same.

  • Accompanied by primary key to a non-unique index?

    Met a weird situation today. A utility, we set up which allows analysts to restore the data in their paintings, started failed when it attempted to drop an index. The index supported a primary key. Makes sense. But our script was supposed to be only an attempt to drop/recreate the nonunique indexes. It turns out that supported on the primary key index was not unique and to the best of my knowledge has emerged as follows:
    SQL> create table junk (f number(1));
    
    Table created.
    
    SQL> create index junk_ix on junk(f);
    
    Index created.
    
    SQL> select UNIQUENESS from DBA_INDEXES where index_name = 'JUNK_IX';
    
    UNIQUENES
    ---------
    NONUNIQUE
    
    SQL> alter table forbesc.junk add constraint junk_pk primary key (f) using index junk_ix;
    
    Table altered.
    
    SQL> select UNIQUENESS from DBA_INDEXES where index_name = 'JUNK_IX';
    
    UNIQUENES
    ---------
    NONUNIQUE
    
    SQL> insert into junk values (1);
    
    1 row created.
    
    SQL> insert into junk values (1);
    insert into junk values (1)
    *
    ERROR at line 1:
    ORA-00001: unique constraint (FORBESC.JUNK_PK) violated
    
    
    SQL> select index_name from dba_constraints where constraint_name = 'JUNK_PK';
    
    INDEX_NAME
    ------------------------------
    JUNK_IX
    What I can't understand, is how an index is not unique is to apply oneness. I thought it was the key to this process. I thought that perhaps an index with the 'SYS_123456' has be created, perhaps, but I couldn't find a:
    SQL> select object_name, object_type from dba_objects order by created desc;
    
    
    OBJECT_NAME   OBJECT_TYPE
    -------------------------------------------     
    JUNK_IX     INDEX
    JUNK     TABLE
    ...
    How the uniqueness is get applied in this case? It comes in Oracle 11.1.0.7

    Thank you
    -= Chuck

    It has always been like that. Oracle can and will use a non-unique index to apply a constraint to PK, the existing index just needs to have the columns PK as the leader or the columns in the index:

    SQL> create table t (id number, id1 number, descr varchar2(10));
    
    Table created.
    
    SQL> create index t_ids on t(id, id1);
    
    Index created.
    
    SQL> select index_name from user_indexes
      2  where table_name = 'T';
    
    INDEX_NAME
    ------------------------------
    T_IDS
    
    SQL> alter table t add constraint t_pk
      2  primary key (id);
    
    Table altered.
    
    SQL> select index_name from user_indexes
      2  where table_name = 'T';
    
    INDEX_NAME
    ------------------------------
    T_IDS
    
    SQL> insert into t values (1, 1, 'One');
    
    1 row created.
    
    SQL> insert into t values (1, 2, 'Two');
    insert into t values (1, 2, 'Two')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (OPS$ORACLE.T_PK) violated
    

    John

  • Difference of path between primary key and a Unique Index

    Hi all

    Is there a specific way the oracle optimizer to treat differently the Primary key and Unique index?

    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 data test for Index Normal
    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> 
    Examples of test when using primary key data
    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 same even as the statistics were gathered,
    * In the 1st table T_TEST_TAB, table always use FULL table access after creating indexes.
    * And in the 2nd table T_TEST_TAB1, table uses PRIMARY KEY as expected.

    Any comments?

    Kind regards
    BPat

    >
    * In the 1st table T_TEST_TAB, table always use FULL table access after creating indexes.
    * And in the 2nd table T_TEST_TAB1, table uses PRIMARY KEY as expected.
    >
    Yes - for the first table a full table scan will be used as the currently selected column is nullable and indexes do not include null values.

    The index can be used for the second query, since all the data (first column) is available between the index and there may be no NULL values because of the primary key. If you check constraints, you find that the there is now a CHECK constraint to ensure that the first column cannot be null.

    For a full and interesting discussion see the explanation of this and a related issue on the question I ask in this thread
    What SYS tables (not seen) contain the value NULL spec /not/ column definition? and my response he posted: 23 April 2012 09:02

    I ask the question is based on a question here which is similar to yours
    Columns becoming nullable after a fall of primary key?

  • Descendant of primary key

    Hello everyone.
    Is there a way to create the primary key by order of decreasing its index?
    I have a sql for MSSQL that looks like:

    ALTER TABLE table_name ADD CONSTRAINT pk_name
    KEY elementary SCHOOL (Column1 Column2 Column3 DESC, DESC, DESC)

    How can I make in Oracle?

    I tried this:

    ALTER TABLE table_name

    ADD CONSTRAINT PRIMARY KEY pk_name

    *(*
    Column1 DESC
    *, Column2 DESC *.
    *, Column3 DESC *.
    *)*
    ENABLE;

    but I got this error:

    Error report:
    SQL error: ORA-00907: lack the right parenthesis
    * 00907. 00000 - "lack the right parenthesis."
    * Question: *.

    * Action. *

    A reverse key index is distinguished by an index of desc.

    I don't think that you can create a descending index to support a primary key because in Oracle a descending index is implemented as an index based on a function by using SYS_OP_DESCEND.

    But you can create a unique index, for example

    CREATE UNIQUE INDEX  ON  (
    

    The question is always why.

    You can use an ascending index to make a descending sort. Maybe cannot MSSQL?

  • Drop primary key

    Hello

    Using the version of database

    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
    AMT for Solaris: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production


    When I use the command alter table < tablename > drop drop key primary index. the primary key and the corresponding index falls.

    But when the same code is run in the environment SIT the associated primary key column became able NULL. Is it because of an incompatibility of versions of database? In my environment of the column is NOT yet Bull.

    Can someone help me on this

    Probably in a database of the column was already NOT NULL before creating the primary key constraint, and Oracle does not need to implicitly not null.
    In other databases, there is no constraint NOT NULL, so when the primary key has been abandoned, the constraint was also missing.

    Question of control procedures insufficient source, nothing to do with the versions of database.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • modify a primary key constraint

    Hello

    I start with oracle, and I have two doubts which cannot handle after a search on the internet.

    1. it is possible to do an ALTER TABLE for a DEFAULT CONSTRAINT?. Maybe you think that the question should be in a different way like this: oracle database takes the default condition as a constraint?. As far as I know, not done that.

    2. it is possible, with an ALTER TABLE to CHANGE a CONSTRAINT of a PRIMARY KEY, to add another field more?

    I searched the internet, but I have not found a clear answer. I use oracle 10g express edition.


    Thank you very much.

    P.D.:sorry for my English, it is not very good.

    #2-you can not 'add a column to the primary key of a table constraint' with a single ALTER, but you can delete and re-create the constraint primary key (including the additional column).

    13:25:26> create table t1 (a number primary key, b number, c number );
    
    Table created.
    
    Elapsed: 00:00:00.09
    13:25:46> alter table t1 drop primary key;
    
    Table altered.
    
    Elapsed: 00:00:00.06
    13:25:47> alter table t1 add primary key (a,b);
    
    Table altered.
    
    Elapsed: 00:00:00.09
    

    But you will not be able to drop the primary key of a table index.

    13:25:47> create table t2 (a number primary key, b number, c number ) organization index;
    
    Table created.
    
    Elapsed: 00:00:00.03
    13:25:59> alter table t2 drop primary key;
    alter table t2 drop primary key
    *
    ERROR at line 1:
    ORA-25188: cannot drop/disable/defer the primary key constraint for
    index-organized tables or sorted hash cluster
    
    Elapsed: 00:00:00.00
    13:25:59> 
    

    #1-I'm not sure I understand your question, but you can change a table column to have a default value. This isn't a "constraint", but a default value. It has an effect when you perform an insert which does not include this column.

    13:31:23> alter table t1 modify (c default 3.14);
    
    Table altered.
    
    Elapsed: 00:00:00.04
    13:31:24> insert into t1 (a,b,c) values (1,2,3);
    
    1 row created.
    
    Elapsed: 00:00:00.01
    13:31:24> insert into t1 (a,b,c) values (4,5,NULL);
    
    1 row created.
    
    Elapsed: 00:00:00.00
    13:31:24> insert into t1 (a,b) values(6,7);
    
    1 row created.
    
    Elapsed: 00:00:00.01
    13:31:24> select * from t1;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
             4          5
             6          7       3.14
    
    3 rows selected.
    
    Elapsed: 00:00:00.18
    
  • creating a unique index of instaed of using the primary key index

    Hello

    I heard in a debate sometimes it is better to create a unique index on a column and use it instead of using the primary key index in oracle. I did not understand what that the reason propely.

    Can someone please help me in this topic if it is valid.

    Thanks in advance

    On the surface, which does not seem reasonable... Volume of the DML is irrelevent to determine which column is the primary key for a table.

    My wild speculation a bit at a reasonable time could someone do...

    If you use synthetic primary keys (i.e. the keys generated by sequence) and that your tables are subject to large volumes of inserts such as there is a danger that the block "to the right" will be the source of contention block and worry not about analysis of beach on the column, you can create a reverse on this column (unique or non-unique) key index before creating the primary key constraint and to indicate Oracle to use this existing index to respect the primary key constraint.

    Obviously, however, this involves a lot of assumptions to arrive at a reasonable point. There may well be another set of assumptions that could also lead to a valid argument. Or it could be a myth that someone has heard and just repeats.

    Justin

Maybe you are looking for