Change of primary key?

Hello

I understand that the change to the primary key on a table enabled version is not possible. What is the proposed route of action then?

Disable versioning, change of PK and reactivate the version control? Unfortunately, it is not as simple as that because I FKs to other tables enabled version. I would avoid cascading disable version (I have the impression it will spread most of the schema)

Can I just delete the table and re-create it with the new PK and then reactivate the version control?

Hello

You are right. The only way to change the primary key is to run the dbms_wm.disableversioning on the table. Is there are tables that are related through foreign key constraints, then you can drop/disable these constraints and then reactivate once the table has been modified with the new primary key. This will allow you do not have to call disableversioning on several tables.

Kind regards
Ben

Tags: Database

Similar Questions

  • Change of primary key on the Table clears the other columns

    Preliminary info/Installation
    JDeveloper 11 g 11.1.1.6.0
    We have a table (object view or entity) that has 8 columns. The primary key is composed of 4 1 columns.
    The table is displayed in a page fragment.
    2 of the 4 non-primary key columns are LOV.
    All the 8 columns are needed.
    The table is editable including 2 of primary key columns.

    Question
    Assume that the table displays the 3 lines. If we change a rank 1 non-primary key column and a primary key in row 2 column, everything works well when we are committed to the database
    If, however, we first change a primary key column, then a primary key on a different line column, then the column/row primary key that changed us first, gets annihilated and the other columns LOV on this same line. The 2 columns that are not LOV keep data as it should. We then get a validation error because the required data are not present. All this happens before we try all commit to the database. If debug us and look the iterator, it has the old data in this document, before and after any performance on the binding.
    If we look at and update the data via the App Module, everything works well. We have tried to update the view, etc. through valueChangeListener also with no luck.

    If you change the primary key value, it should not be the primary key.

    This is true in the design of database relational regardless of how access you the data. In addition, EO don't like if you change the primary key value.

    Have you considered adding a surrogate key (use a sequence) and make your PK course a unique key?

    John

  • Another user has changed the primary key

    uses 11.1.1.5.0 - adfbc jdev

    After each insertion while saving the recording
    get error like this > > > another user has changed the primary key

    What should I do to avoid this?
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <BC4JConfig version="11.1" xmlns="http://xmlns.oracle.com/bc4j/configuration">
       <AppModuleConfigBag ApplicationName="com.rits.glm.model.servicesAM.generalLedgerAM">
          <AppModuleConfig DeployPlatform="LOCAL" JDBCName="goodwell" jbo.default.country="IN" jbo.project="com.rits.glm.GeneralLedger" name="generalLedgerAMLocal" ApplicationName="com.rits.glm.model.servicesAM.generalLedgerAM">
             <Database jbo.locking.mode="optimistic"/>
             <Security AppModuleJndiName="com.rits.glm.model.servicesAM.generalLedgerAM"/>
          </AppModuleConfig>
          <AppModuleConfig DeployPlatform="LOCAL" JDBCName="goodwell" jbo.default.country="IN" jbo.project="com.rits.glm.GeneralLedger" name="generalLedgerAMShared" ApplicationName="com.rits.glm.model.servicesAM.generalLedgerAM">
             <AM-Pooling jbo.ampool.dynamicjdbccredentials="false" jbo.ampool.isuseexclusive="false" jbo.ampool.maxpoolsize="1" jbo.ampool.resetnontransactionalstate="false"/>
               <Database jbo.locking.mode="optimistic"/>
             <Security AppModuleJndiName="com.rits.glm.model.servicesAM.generalLedgerAM"/>
          </AppModuleConfig>
       </AppModuleConfigBag>
    </BC4JConfig>

    a few suggestions
    Houston-25014: another user has changed...
    http://adfhowto.blogspot.com/2010/12/troubleshooting-another-user-has.html
    Another user changed the row with primary key

  • Changing a primary key field

    Hi all

    I would like to provide a mechanism for users to modify primary key (ID), a table in the database by using the ApEx. I wrote a page of PL/SQL for this process. The page process works for updates on the amounts, title, name and surname, but it does not work on the update on the primary key field. See the code below:
    DECLARE
    
       v_total_invested EXC_FIS.FIS_APPLICANT_TOTALS.TOTAL_INVESTED%Type;
       v_total_repatriated EXC_FIS.FIS_APPLICANT_TOTALS.TOTAL_REPATRIATED%Type;
       v_amount_rand EXC_FIS.FIS_APPLICANT_TOTALS.TOTAL_INVESTED%Type;
       v_old_id EXC_FIS.FIS_APPLICANT_INFO.APPLICANT_IDNUMBER%Type;
    
       v_total   NUMBER;
    
    BEGIN
    
       v_amount_rand := :P70_AMOUNT_RAND;
    
       select applicant_idnumber
       into v_old_id
       from EXC_FIS.FIS_FORM_DATA
       where sequence_number = :P70_SEQUENCE_NUMBER;
    
       select total_invested, total_repatriated
       into v_total_invested, v_total_repatriated
       from EXC_FIS.FIS_APPLICANT
       where applicant_idnumber = v_old_id;
       
       v_total_invested := v_total_invested + v_amount_rand;
    
       v_total := EXC_FIS.GET_ALLOWED_AMT() - v_total_invested + v_total_repatriated;
    
      IF v_total < 0 THEN
       
       if EXC_FIS.APPLICANT_ENTRY_EXIST(:P70_APPLICANT_IDNUMBER) = false
      then
          insert into EXC_FIS.FIS_APPLICANT_INFO (APPLICANT_IDNUMBER,TITLE,NAME,SURNAME,APPLICANT_DATE_UPDATED,
                                      TRIMMED_IDNUMBER)
          values(:P70_APPLICANT_IDNUMBER,:P70_TITLE,:P70_NAME,:P70_SURNAME,
                                    SYSDATE,substr(:P70_APPLICANT_IDNUMBER,1,10));
    
         commit;
    
      else
    
          update EXC_FIS.FIS_APPLICANT set Title = :P70_TITLE, Name = :P70_NAME, Surname = :P70_SURNAME, Total_Invested = v_total_invested, Available_Investment_Amount = v_total, TOTALS_FLAG = 'Y', TOTALS_UPDATED = SYSDATE where applicant_idnumber = :P70_APPLICANT_IDNUMBER; 
      
       commit;
    
      end if;
    
      if EXC_FIS.TOTAL_ENTRY_EXIST(substr(:P70_APPLICANT_IDNUMBER,1,10)) = false
      then
        insert into EXC_FIS.FIS_APPLICANT_TOTALS(TRIMMED_IDNUMBER, TOTAL_INVESTED,TOTAL_REPATRIATED,
                                    AVAILABLE_INVESTMENT_AMOUNT,FLAG,TOTALS_DATE_UPDATED)
        values(substr(:P70_APPLICANT_IDNUMBER,1,10),v_total_invested,          v_total_repatriated,v_total, 'Y',SYSDATE);
    
        commit;
    
      else
    
        update EXC_FIS.FIS_APPLICANT set Title = :P70_TITLE, Name = :P70_NAME, Surname = :P70_SURNAME, Total_Invested = v_total_invested, Available_Investment_Amount = v_total, TOTALS_FLAG = 'Y', TOTALS_UPDATED = SYSDATE where applicant_idnumber = :P70_APPLICANT_IDNUMBER; 
      
        commit;
    
      end if;
    
      ELSE
    
       if EXC_FIS.APPLICANT_ENTRY_EXIST(:P70_APPLICANT_IDNUMBER) = false
      then
          insert into EXC_FIS.FIS_APPLICANT_INFO (APPLICANT_IDNUMBER,TITLE,NAME,SURNAME,APPLICANT_DATE_UPDATED,
                                      TRIMMED_IDNUMBER)
          values(:P70_APPLICANT_IDNUMBER,:P70_TITLE,:P70_NAME,:P70_SURNAME,
                                    SYSDATE,substr(:P70_APPLICANT_IDNUMBER,1,10));
    
         commit;
    
      else
    
          update EXC_FIS.FIS_APPLICANT set Title = :P70_TITLE, Name = :P70_NAME, Surname = :P70_SURNAME, Total_Invested = v_total_invested, Available_Investment_Amount = v_total, TOTALS_FLAG = 'N', TOTALS_UPDATED = SYSDATE where applicant_idnumber = :P70_APPLICANT_IDNUMBER; 
      
       commit;
    
      end if;
    
      if EXC_FIS.TOTAL_ENTRY_EXIST(substr(:P70_APPLICANT_IDNUMBER,1,10)) = false
      then
        insert into EXC_FIS.FIS_APPLICANT_TOTALS(TRIMMED_IDNUMBER, TOTAL_INVESTED,TOTAL_REPATRIATED,
                                    AVAILABLE_INVESTMENT_AMOUNT,FLAG,TOTALS_DATE_UPDATED)
        values(substr(:P70_APPLICANT_IDNUMBER,1,10),v_total_invested,
                                 v_total_repatriated,v_total, 'N',SYSDATE);
        commit;
    
      else
    
        update EXC_FIS.FIS_APPLICANT set Title = :P70_TITLE, Name = :P70_NAME, Surname = :P70_SURNAME, Total_Invested = v_total_invested, Available_Investment_Amount = v_total, TOTALS_FLAG = 'N', TOTALS_UPDATED = SYSDATE where applicant_idnumber = :P70_APPLICANT_IDNUMBER; 
      
       commit;
    
      end if;
       
      END IF;
    EXCEPTION
    
       WHEN OTHERS THEN
    
       apex_application.g_print_success_message := '<span style="color:black">Action Processed.</span>';
    
    END;
    Any help is appreciated with kindness.

    Concerning
    -Kamo

    Hi Kamo,

    What ID you want to update? The ID of the applicant (the master) or retail?
    Implement you referential integrity in your database (with restrictions)?
    If you do... you IMPOSSIBLE, simply, change the ID of the master. You would create better two identifiers: an 'external': visible to the user and can be changed. and an 'internal': used to unmodifiable and referential integrity.

    If you really, really, want to continue on your current path - mal - to solve your problem, you have the following options:
    -disable referential integrity and update the codes of the masters of master and detail using a copy of the original ID in your form (you will have two here: P70_ORG_APPLICATNTS_ID and P70_APPLICANTS_ID, the latter can be change) and change your pl/sql code.
    -Keep your referential integrity, but replace it with "DEFERRABLE" (validate on commit - then rethink your validation strategy, see the doc);
    -Keep your referential integrity, but change the code of your pl/sql: an update of an ID results in an insert (the master and details using the new ID) and a removal of the old stuff.

    Greetings,
    Roel

    http://roelhartman.blogspot.com/

  • change a composite primary key


    Hello

    I have a table that has a composite primary key with 3 columns (col1, col2, col3)

    Now I need to change the primary key (col1, col2, col4) remove composite col3 replace with col4

    col1 col2 COL3 COL4 col5
    1onexpDFD
    1oneTherepDFD
    1onezpSD
    1onempamplifier
    1onenpTry

    There are thousands of records in the table in the format above. How to make this change?

    Thank you.

    In this case, you will need to establish that if the change to the primary key makes sense - if so, you'll have to remove some lines to remove duplicates. I think that if this requirement has been raised at a request of the company, they will (should) have indicated what lines need to be maintained.

    If it is not sensible, you will need to go to the one who asked for the change and get them to change their mind or tell you what to do with duplicate lines.

    Out of curiosity, why did you change the primary key?

  • SQL Data Model 3.0 EA1 trying to create the primary key on OT

    Hello

    I am trying to change a primary key of a table of the object that has been reversed (imported) from an Oracle 11.2.x RDBMS and get the error message "the incomplete Index Definition. It is displayed in the window "columns transfer Index." I get to the window"properties of primary key 'by pressing the 'Properties' button on the 'table properties'-> 'Primary key'. If I try to change the expression, and then press Ok or apply buttons I get the error. With this be corrected in the production version? That we will be able to create a model in the SQL Developer Data Modeler, which generates a SQL statement similar to the following:

    ALTER TABLE x_flags
    ADD (CONSTRAINT x_flags_pk PRIMARY KEY (flags.id))

    ?

    Thank you
    Scott K

    Hi Scott,.

    I am trying to change a primary key of a table of the object that has been reversed (imported) from an Oracle 11.2.x RDBMS and get the error message "the incomplete Index Definition"... With this be corrected in the production version?

    Yes

    That we will be able to create a model in the SQL Developer Data Modeler, which generates a SQL statement similar to the following:

    ALTER TABLE x_flags
    ADD (CONSTRAINT x_flags_pk PRIMARY KEY (flags.id))

    I guess that 'flags' is the type of the object column and 'id' attribute of this type. I logged for this bug, there are however not for 3.0.

    Philippe

  • Complex validation of form on a primary key

    I have one that inserts/updates a table with a column 2 primary key (ticket_num, ticket_seq). Is there anyway to create a page validation feature that will prevent some users from the pk constraint violation and get the error ORA-00001 ugly.

    I think that I do not understand the syntax of the validation "SQL Expression".

    I would like to just find if the key already exists, but the following does not seem to catch it. I put the following in the expression of validation 1.

    (select count (*)
    of system_issue_timings
    where ticket_num =: P3_TICKET_NUM
    and ticket_seq =: P3_TICKET_SEQ) > 0

    The pl/sql with count (*) above will not work as select count (*) in... will never trigger no_data_found, it will result in zero in v_test.

    The other thing to watch for on this type of validation (that they are implemented as sql does not exist or as pl/sql return a Boolean or pl/sql to return to error), it is that if you do updates on this page, you must either:
    1 does not fire validation in update (assuming that you cannot change the primary key columns on the page), or
    2 specifically exclude the line updated validation research (for example using the rowid) otherwise it will comply with the condition and the validation fails.

    You probably want to use 'sql NOTexists' validation as it "passes if the query returns no row.":

    Select 1
    of system_issue_timings
    where ticket_num =: P3_TICKET_NUM
    and ticket_seq =: P3_TICKET_SEQ

    Glen

    Published by: gjmorris on September 24, 2008 13:02 - added real solution.

  • How can I make sure that changes in a primary key (in the parent table) would also appear directly in the FOREIGN KEY in the child table?

    Forgive my question. I am very new to Oracle.

    How can I make sure that changes in the key primary supplier_id (concerning the supplier table) would also appear directly in the FOREIGN KEY (supplier_id) in the products table?

    Is that not all the primary key and FOREIGN KEY on?

    My paintings:

    I created 2 tables and connect to apply in the data base referential integrity, as I learned.

    CREATE TABLE - parent provider

    (the numeric (10) of supplier_id not null,)

    supplier_name varchar2 (50) not null,

    Contact_Name varchar2 (50).

    CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)

    );

    CREATE TABLE - child products

    (the numeric (10) of product_id not null,)

    supplier_id numeric (10) not null,

    CONSTRAINT fk_supplier

    FOREIGN KEY (supplier_id)

    REFERENCES beg (supplier_id)

    );

    I inserted the following text:

    INSERT INTO provider

    (supplier_id, supplier_name, contact_name)

    VALUES

    (5000, 'Apple', 'first name');

    I expect that the supplier_id (5000) to the provider of the table also appears in the products table under key supplier_id having the same value which is 5000. But this does not happen.

    How to get there?

    Thanks in advance!

    Hello

    What is a foreign key in Oracle?

    A foreign key is a way to ensure referential integrity in your Oracle database. A foreign key means that the values of a table must appear also in another table.

    Ok!??

    What is now the right way to implement referential integrity in your Oracle database that the values of a table must also be included in another table?

    A foreign key referential integrity indeed enfore in ensuring that the value in the child table must have a corresponding parent key (otherwise you will encounter an error, as evidenced by "SomeoneElse"). However, it will never automatically insert a row in the other table.

    If you are looking for a solution that automatically inserts a record in the other table, maybe you should go for triggers:

    See:

  • Another user changed the row with a primary key oracle.jbo.Key]

    I see many discussions about this error, but still cannot understand the difficulty that I need in my scenario.

    I am an Oracle Developer and completely new to ADF, please bear with me.

    I use JDeveloper 11.1.1.9.0

    My scenario:

    Creates an object editable view (UVO) with sub selects in the query, which is from several db tables.

    Creating a table using the UVO

    When I try to update a field in the table, and then click the validate, I get the error message:

    Another user changed the row with a primary key oracle.jbo.Key]

    Can someone explain in what scenarios I see this error and how do I solve this problem?

    Try the viewObject execution after validation and reQueryOnCommit set to true

    For details see - binary: a reason more for "Houston-25014: another user has modified the line containing oracle.jbo.Key primary key '

    Ashish

  • What is this error represents "another user has changed the line containing oracle.jbo.Key [21 primary key]."

    Mr President.

    What is this error represents "another user has changed the line containing oracle.jbo.Key [21 primary key]."

    Concerning

    You get this exception quite often when you have a business in PL SQL layer, but you can safely ignore (suppress) it by substituting the lock() method in all implementation of your entity classes.

    /*** customizing locking management: 
    * Because attribute values can change 'outside' ADF standard life cycle, 
    * when optimistic locking executes, the exception "Another User Changed the Row" is thrown. 
    * In this case, we execute locking again, ignoring the exception 
    */ 
    public void lock() 
    { 
     try 
     { 
      super.lock(); 
     } catch (oracle.jbo.RowInconsistentException e) 
     { 
      if (e.getErrorCode().equals("25014")) 
      { 
      super.lock(); 
      } 
      else throw e; 
     } 
    }
    
  • When I change a column is a primary key the associated non-unique index to become unique?

    So basically I already tried this and it shows me that the associated index is not unique.

    create table employees2 in select * from employees;

    create index emp_idx on employees2 (employee_id);

    ALTER employees2 table add primary key (employe_id) using index emp_idx;

    Select * from user_indexes where index-name = "EMP_IDX";

    I was wondering if I right assuming that when you change a column to a primary key or unique while using a given index that does not have the respective index become unique.

    The textbooks I use are sometimes a little hard to understand because of the wording, also, I want to just ask someone with a little more experience than me.

    Thank you.

    your test did give the correct answer: the index is not unique if it serves to bear a unique or primary key constraint. Indeed, it is one of the benefits of the use of no unique indexes in support of UK/PK constraints (since it allows to set the unusable index before to make bulk loads; and, of course, they have also some disadvantages - for example, they need an additional logical reading to reach a line). Richard Foote explains the details in https://richardfoote.wordpress.com/2008/06/04/primary-keys-and-non-unique-indexes-whats-really-happening/ (and other items).

  • changing column addition of primary key constraint

    How to change a table and edit a column and add a primary key constraint?

    987018 wrote:
    can add us a primary key constraint by using the command Edit?

    If the column already exists, and there is no existing primary key, then

    SQL> create table t (id number, descr varchar2(10));
    
    Table created.
    
    SQL> alter table t modify (id not null primary key);
    
    Table altered.
    

    If the column does not exist yet and there is no primary key, then:

    SQL> create table t1 (descr varchar2(10));
    
    Table created.
    
    SQL> alter table t1 add (id number not null primary key);
    
    Table altered.
    

    John

  • How to change the type of source for a primary key on a form?

    Hello

    When creating a form, I put the source type for the primary key of an existing sequence.

    Now, I want to change the source of a trigger.

    Can anyone suggest how do?

    Thanks in advance,
    Annie

    Annie:

    Set the trigger and then delete the process of the page named «Get PK»

    CITY

  • APEX do not allow to change the lines of the columns that are the primary key?

    I have pictures:
    http://img508.imageshack.us/my.php?image=21269582oe8.jpg


    Book (id_book - 'Primary key', title, year); book_author (id_author id_book - 'Primary key', - 'Primary key'); author (id_author - "Primary key", name)



    I created a new page-> Form-> form of 'author' table because I want to add new authors, modification and deletion. During the creation of this page, I have chosen column 'id_author' as '1 primary key column' and everything is OK (I can't edit the 'id_author' column - this column is autoincrement and I can change the 'name' column).

    BUT I also created a new page-> Form-> table for table "book_author" because I like to write numbers like id_book and id_author, change and remove them (so add relations between tables: book, book_author and author). During the creation of this page, I have chosen column 'id_book' as '1 primary key column' and 'id_author' as 'column primary key 2'. And on the Web site, I can't edit these fields. And I can not add also new line because I see in each new line: (null).

    http://img444.imageshack.us/my.php?image=11324615yk9.jpg

    APEX do not allow to change the lines of the columns that are the primary key? It's stupid... What can I do?

    Edited by: user10731158 2008-12-20 11:40

    Column unique and not meaningful if you ever want to update. In the case of your example, you need to add an ID column in the intersection of book_author table. Honestly, I was so blown away (and pleasantly surprised) by the absence of rebuttal and the "thx" I advanced and set up an example of how I would define the book_author table:

    create table  book_author
       (id varchar2(32),
        book_id varchar2(32),
         author_id varchar2(32),
         modified_on     date,
         modified_by varchar2(255),
         constraint book_author_pk primary key (id),
         constraint book_auth_book_fk foreign key (book_id) references books(id),
         constraint book_auth_author_fk foreign key (author_id) references authors(id)
         )
    /
    
    create unique index book_author_uq on book_author (book_id,author_id)
    /
    
    create or replace trigger  biu_book_author before insert or update on book_author
    for each row
    begin
         if inserting then
              :new.id := sys_guid();
         end if;
         modified_on := sysdate;
         modified_by := nvl(v('APP_USER'),user);
    end;
    /
    

    Good luck
    Tyler

  • Change/Remove primary parent

    Hello

    I need to change the primary parent on behalf of Microsoft family safety from one parent to another parent.

    How can this be accomplished?

    Thank you

    Arlo

    Hello

    To change the primary parent account that is associated with your child's account, you need to remove the primary parent. This will remove all restriction settings you requested to your child. After removing the primary parent, you will need to restore on behalf of the child under the new primary parent and the installer restriction again. To do this, please follow the steps below:

    1. go to https://familysafety.microsoft.com and sign up using the primary parent account.

    2. after accessing it, you will see the main page and a list of family members who are associated with the account main parent. Click manage the list of the members of the family , this option is next to make a family member, a parent.

    3. on this page, you can remove the Member who is under your account. You can also remove the primary parent by clicking on the checkbox next to the name of the main account.

    4. Once you have chosen, all members that are related to your account will be also included.

    5. click on the Remove button and confirm the operation.

    Once this has been done, you will have to restore on behalf of the child under the new primary parent account. To do this, please follow the steps below:

    Add/Re-adding a child (with a Microsoft account) for parental control in Windows 8

    In Windows 8, you can use accounts of Microsoft as a user. You just link the Microsoft e-mail account to the new standard user. Follow these steps:

    Note: Make sure that you have an internet connection to create a user with a Microsoft account.

    1. press Windows key on your keyboard to access the applications screen.

    2. tap create an account (you will be redirected to search application screen automatically).

    3. click on settings (second option with the gear icon).

    4. click on create an account on the selection to the left pane. (You may be prompted for access admin select an admin user, and then enter the administrator password).

    5. in the account management window, click Add a user account.

    6. you will be prompted to add a user, enter the Microsoft account email address in the text box then click on Next.

    7. check This is a child account? Turn on family safety for PC usage reports.

    8. click on Finish.

    After you create the child account, you can then go to the Family Safety website, log in using the parent account and then manage restrictions and control of your child options.

    Let us know the result later.

    Thank you.

Maybe you are looking for

  • How to save a backup on the web in a specific folder on my Mac?

    When I try to save an image on my Mac - I have the ability to save on my desktop, my Docs folder, or some other, but not in a specific folder for different things, think I'm saving. I can't scroll the My Documents folders for example and save it to o

  • Certificate error on one of the two identical systems?

    I recently installed Ubuntu 12.04, PC01 and PC02 two COMPLETELY identical systems. The browser is the latest version of Mozilla Firefox. When visiting https://www.komplett.dk/k/signin.aspx with cp01, the connection is secured and everything is OK, no

  • When Fire Fox made the transfer to the other computer?

    Sync is done until the closure of the browser?Every hour?Once a day?Once a week?What happens if two computers are turned on?

  • VISA is a non-existent port...

    Hello We replaced our old computer laboratory with a new model and took the opportunity to also move to a more recent operating system (from Win XP to Win 7 64 bit) and to the current version of the CVI (2013 SP2) and its runtime of all device driver

  • MIME content type for text files

    Hi, I want to send a text file. Type the conent to make this 'text' or is ' text/plain '? Thank you David