Can I modify primary key or I need to drop it to create another overhide?

I am getting this issue when I try to create another primary key in my table. The example bellow express the situation.
TABLE AAA
(ID
NAME
REGISTER)
PK: ID
I cannot drop the primary key, cause the table have some FK, so, I was thinking about to try "modify" this key (to put too other field), but I have not found one way to do it, I think just I can drop out the FKs, drop PK after, and create another new primary key after all, but this issue can be bring on a big trouble with other tables, there is another way to fix it, modifyng or just overhide the key?
Thanks all and apologize about my bad english!

Disable the refrencing FKs, then drop and recreate the PK. You will also have to modify the FKs. You can, alternatively, create a unique constraint on the new column combination.

Similar Messages

  • How can i set primary key after creating a table ?

    hi friends
    thank you for all the support you have given me . i have doubt ,can we set primary key for a column after creating the table
    I have added a column named idno after creating the table . i want to set that column as primary key . i tried this
    table name = address
    column name = idno
    ALTER TABLE ADDRESS MODIFY (idno PRIMARY KEY(idno))
    ,but not working
    if anbody knows the solution pls reply
    thanks and regards
    nev

    how does the other users know which is the primary key for this table?....the other user needs to execute this query...and modify the query accordingly
    select aa.table_name,aa.column_name,aa.constraint_name,bb.constraint_type
    from user_cons_columns aa,user_constraints bb
    where aa.constraint_name = bb.constraint_name
    and aa.table_name = 'TEST_EMP' and bb.constraint_type = 'P';

  • How to modify primary key column?

    I want to modify one primary key column, But TT reported error.
    How do I modify primary key column? Thanks first.

    In TimesTen, the values in primary key columns cannot be updated (except for the trivial case where you update the value to the same value as it currently has). If you want to change the values stored in primary key columns the application must insert a new row with the new key values (and of course values for the other columns) and then delete the old row.
    Chris

  • Can a composite primary key column be null

    Hi All,
    It will be a silly question but still I would like to ask can a composite primary key column be null?
    Thanks,
    Rafi.

    Rafi,
    Why you think it would be allowed?
    SQL> drop table test purge;
    drop table test purge
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> create table test as select * from dba_objects;
    Table created.
    SQL> alter table test add primary key(object_id, owner);
    Table altered.
    SQL> insert into test(object_id, owner) values(null, 'aman');
    insert into test(object_id, owner) values(null, 'aman')
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OBJECT_ID")
    SQL> insert into test(object_id, owner) values(1,null);
    insert into test(object_id, owner) values(1,null)
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OWNER")
    SQL>HTH
    Aman....

  • Modify Primary Key Value while present in child tables

    Hi,
    I have one master table having primary key "ESTNO" and 10 child tables having ESTNO as the part of their primary key / composit key. I need to update the value of ESTNO in a master and associated child tables. what should i do to accomplish this...
    Regards.

    I think the trigger is the best solution to a bad problem. Having just tested it, I can confirm that putting the code in the AFTER UPDATE ... FOR EACH ROW trigger does not require us to make the foreign key deferred (at least in 9.2, I assume that also applies in earlier versions).
    Cheers, APC
    ALTER TABLE t2 ADD CONSTRAINT t2t1_fk FOREIGN KEY (col2) REFERENCES t1(col1)
    SQL> CREATE OR REPLACE TRIGGER "APC_LOAD"."T1_AUR" AFTER
      2  UPDATE ON "APC_LOAD"."T1" FOR EACH ROW BEGIN
      3  IF :NEW.col1 <> :OLD.col1 THEN
      4     UPDATE t2
      5     SET t2.col2 = :new.col1
      6     WHERE t2.col2 = :old.col1;
      7  END IF;
      8* END ;
      9  /
    Trigger created.
    SQL> UPDATE t1 SET col1 = 1 WHERE rownum = 1;
    SQL> SELECT count(*) FROM t1 WHERE col1 = 1;
      COUNT(*)
             1
    SQL> SELECT count(*) FROM t2 WHERE col2= 1;
      COUNT(*)
             1
    SQL>  UPDATE t1 SET col1 = 87979 WHERE col1 = 1;
    1 row updated.
    SQL> SELECT count(*) FROM t2 WHERE col2= 1;
      COUNT(*)
             0
    SQL>
    SQL> SELECT count(*) FROM t2 WHERE col2= 87979;
      COUNT(*)
             1
    SQL>        

  • Who can I update primary key field in master block

    Hi,
    I want to update the primary key field in master block when there are some records are present in detail block, when I edit the primary key filed there is an error FRM-40509 unable to update record. The primary key is also referred by the detail table.
    So kindly give me the solution who can I update the primary key in master block when there is child records exists in detail block?.
    Best regard,
    shahzad

    pls tell us a little more about, why you want to update a PK in a master block.
    I haven't done that my whole time. Maybe you need something different.
    The problem is, that your child-data references to the master-pk, so there is the point you have to go deep into the codings. But better don't do it. Tell us first why. I think there are other solutions for that.
    try it
    Gerd

  • Problem with primary key field that needs updating on commit

    Taking on someone else's form and trying to tidy it up as it has no primary key on tha table.
    The only primary key i can apply is (invoice number, line number)
    This has to be displayed on the form as a provisional number when the user enters the form. So it need to show for example inv number 1000 with each line on the invoice being 1,2,3,4 etc.
    The form then has a linked table for the lines per invoice that inserts invnumber and line number into a seperate table on PRE INSERT trigger. This means that if they put on various lines i need to do a post.
    My problem comes because more than one person can use the form at the same time so user a will go into the form and see inv number 1000, user b will also see 1000. The original form was making these null and updating to correct number on commit but i wanted to add a primary key.
    Im jusat wodering the best way to do this as if user a does not save before user b. there is a potential for a lock to occur on the post. Also they must be updated to a new number if someone else saves before them

    either you create a sequence for this by create sequence command and populate the sequence value. but in this case if the form is cancelled the sequence is missed and the next sequence will appear. Another way to do is to generate the invoice number when the user press save button and then assign that value to text item. It is the best way to do. So the user will see invoice number only when they save and it happens in milli seconds so there is no question of overlapping invoice number.
    Hope this helps.

  • How can I hide primary key column in BC4J form

    I have populated a primary key with dbsequence and how can I hide it on the form. It is populated in the DB by a trigger.

    I have populated a primary key with dbsequence and how can I hide it on the form. It is populated in the DB by a trigger. To hide it, edit the attribute using attribute-editor that you bring up by double-clicking on the attribute in the "StructurePane" .
    Then go to control-hints panel and mark the attribute setting for Display = Hide.
    Then UI wizards will not add the attribute into generated panels.
    However once you have UI generated, this hint is no more used.

  • Database Copy can't copy primary key for tables

    When I use Tools->Database Copy Wizard to copy my existing schema (for example: azteca_KSMMS) to a brand new schema (azteca), I find the primary key for some of the tables can't be copied, also the views seem not valid under the new schema (azteca). Please give me your comments about that. Thanks for your help.
    Kevin

    For example I have a table called workorder, it has a primary key with name (CW_PKEY_519, on WORKORDERID column) from the source schema (azteca_KSMMS). After I database copy to new schema azteca, the primary key lost. The data of workorder and other indexes have been copied to azteca schema.
    Kevin

  • Why can't Verizon lower my bill more than $40 by changing plans? Do I need to drop service and find another carrier?

    I went to Verizon last night to change my plan and the customer service rep was very rude and un helpful. I want to lower my bill and when he couldn't I told him I would have to look into another carrier and his response was okay you can do that but they won't have the coverage we do. Really??!!! That's all you can say to your customer who is about to drop your service??

    customer service can only offer you what's available. They can't just willy nilly offer you discounts. I'm not sure why people don't get this. $40 a month is $500 a year. That's nothing to sneeze at.

  • How can I modify a column to a primary key column

    Hi,
    I've created a table with no primary key. How I can set the primary key column now? The datatype of the "primary key" column is Raw(35).
    Thanks,
    Mike

    Mike,
    Issue the following command:
    ALTER TABLE table_name
    ADD CONSTRAINT constraint_name PRIMARY KEY(column_name);
    NOTE: If you want to place the primary key data in a separate tablespace, then you can add the key word USING INDEX TABLESPACE after the column_name.
    Regards,
    John

  • Can I add a new column to a composite primary key without dropping it?

    Hi
    I need to modify the composite primary key of a table so as to include an another additional column to it?
    Can I do that without dropping the PRIMARY KEY constraint on the table?

    user13410062 wrote:
    Hi
    I need to modify the composite primary key of a table so as to include an another additional column to it?
    Can I do that without dropping the PRIMARY KEY constraint on the table?post results from ALTER TABLE command

  • Can we create an APEX Form based on Table which has no Primary Key

    Hi,
    I have a requirement.
    I need to create a FORM based on a table having no Primary Key but it is having Unique Key . I can use Unique Key as an alternate of Primary Key.
    but When I tried to create a Form, I got the following message.
    Source tables for forms and tabular forms must have a primary key
    Thanks,
    Deepak

    Deepak_J wrote:
    Hi,
    I have a requirement.
    I need to create a FORM based on a table having no Primary Key but it is having Unique Key . I can use Unique Key as an alternate of Primary Key.
    but When I tried to create a Form, I got the following message.
    Source tables for forms and tabular forms must have a primary key
    Thanks,
    DeepakGood database design will always require a PK on the tables. There are only very few and rare expetions to this rule. One would be when you have store the data only temporarily in this table, like it is often done for import/loader tables. The data is first loaded in the "import"-table, then validated and then transported to the "real" tables. In such a scenario you can ignore the primary key on purpose. Because you already have a UK on this table it can't be such a scenario.
    For most other scenarios you should always add a PK. Ask critically why there is no PK on it. Is there a reason for it or was the table designer just not doing its job well?
    Btw: A UK is identical to a PK if the column is mandatory (NOT NULL). In this case you could simply change the constraint from UK to PK.

  • Modify a primary key constraint

    Hi,
    I'm starting with oracle, and I have two doubts that can't handle after searching on the internet.
    1º It's possible to make an ALTER TABLE of a CONSTRAINT DEFAULT?. Maybe you think that the question should be in another way like this: Does oracle database take the default condition as a constraint?. As long as I know, doesn't do that.
    2º It's possible, with an ALTER TABLE, to MODIFY a CONSTRAINT of a PRIMARY KEY, to add another more field?
    I've been searching on the internet, but I didn't find a clear answer. I'm using oracle 10g express edition.
    Thank you very much.
    P.D.:Sorry for my english it's not very good.

    #2 - You can not 'add a column to the primary-key constraint of a table' with a single ALTER, but you can drop and re-create the primary key constraint (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.09But you will not be able to drop the primary key of an index-organized table.
    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 alter a table's column to have a default. This is not a 'constraint', but a default. It only has effect when you perform an insert which does not include that 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

  • How to pass values for compound primary keys for updating the record in db.

    i have a entity bean in my ejb with two primary keys to it...eg. roleid,rolename...
    when iam retriving the record i use only one primary key ...so again to modify and update he same record which i retrived is a pbm..
    i cannot set the values for the compoundpk,,,
    but i can do the update for the bean with single primary key..
    i need to know how to pass the values/parameters for the coumpound primary key in my update method...
    thanx in advance...
    Arjun.G

    I istantiated a object for the pk class and assign the values for the primary key fields...
    Arjun.G

Maybe you are looking for