Issues while changing primary key in table

Hi
I have one table. In that two fields are primary key. I want to change the second PK as FK only. But when i am changing this field as FK. Its showing one error 'Primary Key Change not permitted for value Table ZCAUSECATMASTER' . How to avoid this error.
Please help me.

Hi.....
Remove that primary key for the second field and assign your foregin key..table to that filed.....
So when you give entries in that second filed it will be validated with its foregin key table......its nothing but check table...
what all values in the foregin table only can given.....
regards
raja

Similar Messages

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

    Hi,
    I am trying to delete data from a table by dropping a partition. I have identified all the child tables by running the following command.
    select 'select count(*) from '||table_name||' where employee_id = 100;'
    from 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(*)FROM'||TABLE_NAME||'WHEREEMPLOYEE_ID_ID=100;'
    select count(*) from PT_ORDERS where employee_id = 100;
    select count(*) from PT_DEP where employee_id = 100;
    select count(*) from PT_SKILLSET where employee_id = 100;
    I dropped the partition for employee_id 100 in all of the child tables. The select count(*) returns 0 rows for each of the above.
    When I try to run the below command on the EMPLOYEE table, I get 'ORA-02266: unique/primary keys in table referenced by enabled foreign keys'.
    alter table EMPLOYEE drop partition EMP_ID_100;
    I cant see why I am unable to drop this partition now as there is now child data in any of the referenced tables. Any suggestions or help on this would be greatly appreciated.
    Thanks.
    Rgs,
    Rob

    You should disable foreign key constraints first and drop partition. Deletion of rows or dropping partitions in childs don't work in this case
    as you have the global dependency:
    <PRE>
    SQL> create table scott.t (x int primary key, y int)
    2 partition by list (y) (
    3 partition p_1 values(1), partition p_2 values(2))
    4 /
    Table created.
    SQL> create table scott.t_c (x int references scott.t(x), y int)
    2 partition by list (y) (
    3 partition p_1 values(1), partition p_2 values(2))
    4 /
    Table created.
    SQL> insert into scott.t values(1,1)
    2 /
    1 row created.
    SQL> insert into scott.t values(2,2)
    2 /
    1 row created.
    SQL> insert into scott.t_c values(1,1)
    2 /
    1 row created.
    SQL> insert into scott.t_c values(2,2)
    2 /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter table scott.t_c drop partition p_2;
    Table altered.
    SQL> alter table scott.t drop partition p_2;
    alter table scott.t drop partition p_2
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled 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 table scott.t_c disable constraint SYS_C0011059;
    Table altered.
    SQL> alter table scott.t drop partition p_2;
    Table altered.
    SQL> alter table scott.t_c enable novalidate constraint SYS_C0011059;
    Table altered.
    </PRE>
    I guess you should consider such option as Referencial partitioning (with some restrictions).
    Best wishes,
    Dmitry.

  • Add a primary key to table.

    Hello everybody,
    I want to add a primary key to a table but it doesn't work.
    select count(*), count(id) from tableA;
    COUNT(*) COUNT(ID)
    830447 830447
    You see: The number of ids is equal to the number of rows. The ID is not marked as unique but it should be unique. I try to set id as the primary key:
    alter table tableA add constraint "pk_constraint" PRIMARY KEY (id);
    But I a get an error message: ORA-02437: cannot validate (pk_constraint) - primary key violated.
    What is the problem?
    I use Oracle 11g.

    user9206958 wrote:
    Hello everybody,
    I want to add a primary key to a table but it doesn't work.
    select count(*), count(id) from tableA;
    COUNT(*) COUNT(ID)
    830447 830447
    You see: The number of ids is equal to the number of rows. The ID is not marked as unique but it should be unique. I try to set id as the primary key:
    alter table tableA add constraint "pk_constraint" PRIMARY KEY (id);
    But I a get an error message: ORA-02437: cannot validate (pk_constraint) - primary key violated.
    What is the problem?
    I use Oracle 11g.Revisit your query... 11g can help much in this sql.... select count(*), count(id) from tableA;... to get what your desired output should be.
    Edited by: Z.K. on Mar 30, 2010 1:15 PM

  • Populate choice component  with   2 primary key  in table

    There are 2 primary key in table. When I create my uix with jheadstart, the UIXs don't populate choice component. How can I create automatically populate choice component, with 2 PK in table?

    A choice component can only have one value attribute. So if you have a composite primary key in the table you use to populate the choice, it will not work correctly, because based on this single attribute the choice cannot render the correct row as selected.
    Steven Davelaar,
    JHeadstart Team.

  • Inner join-select -primary key in table issue

    Hi ,
            Iam using FEBKO(header) and FEBEP(item) in inner join  select .But the datas fetching by this selct in not correct.The analysis is the is no common primary fields in the both table.
    Question 1-> Can i use inner join without common primary key in the both tables, weather it possible to make a select without common primary key in both table. Please kindly let me know.
    Question 2-> What is the other possible way to give the selct for both table(better performance)
    Regards,
    Veera

    Hi,
    When you use INNER JOIN in this case, link your tables based on KUKEY and ESNUM fields, bcoz there can be many items under a single header. So this will work for you, even from the performance point of view.
    Hope this is helpful to you. If you need further information, revert back.
    Reward all the helpful answers.
    Regards
    Nagaraj T

  • How to create tabular form whithout primary key in table

    Hi All,
    I have requirement to create a tabular form but the problem is, the table which I am using in the application don't have any Primary key, I am using only one table can't change any thing in table.(i.e can't add any row in table,no change in data model)
    How can I create tabular form when primary key is not available.
    looking forward for all of your quick responce.
    Thanks in advance.
    Dikshit Kumar Nidhi

    You can create a view like
    select a.rowid id, a.*
    from table a
    and create a tabular form on this view. You can use
    the new column ID as Primary key.Did you try to actually do this? I did at
    http://htmldb.oracle.com/pls/otn/f?p=24317:159
    And when I change something and click Submit, I get an error
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-01733: virtual column not allowed here, update "VIKASA"."NO_PK_VW" set "ID" = :b1, "I" = :b2, "J" = :b3 where "ID" = :p_pk_col
    Thanks

  • Change primary key in ztable

    Hello everyone
    I need some advice.
    I have transp. table ZINVOICE which have data in production system.
    field  of table are
    VBELN  Primary key
    KUNNR
    NAME
    FKART
    FKDAT
    NETWR
    STAT
    TAXINVNUM
    ZFKDAT
    ZNETWR
    now i want table ZINVOICE have 2 primary (VBELN + TAXINVNUM)
    when i activate system show
    Key is already defined; field TAXINVNUM cannot be in the key
    Message no. AD434
    Diagnosis
    When defining table fields, you added further key fields at the end after entering a block of key fields followed by a block of non-key fields.
    All the key fields of a table must be in a block at the beginning of the table.
    Procedure
    All key fields in a table should be entered in a single block.
    is it mean that primay key must be in beginning of the table ?
    can i delete field in table ZINVOICE and insert field and change position of fields to
    VBELN  Primary key
    TAXINVNUM Primary key
    KUNNR
    NAME
    FKART
    FKDAT
    NETWR
    STAT
    ZFKDAT
    ZNETWR
    can i do like this ?
    is it impact my existing data in SAP ?
    please advice.

    As you are adding a new key, you should not get problem with duplicate records.
    You should create two transport requests and activate/transport the table twice.
    - In the first request, change the order of fields in the database table, don't add primary key now, activate , if required adjust database table (should not be required), transport database table in target system.
    - In the second request, declare the second field as a primary key, proceed same way.
    DON'T TRANSPORT BOTH REQUESTS TOGETHER
    First step
    VBELN K
    TAXINVNUM
    KUNNR
    NAME
    Second step
    VBELN K
    TAXINVNUM K
    KUNNR
    NAME
    Question: Did you forget to add the client field, if yes you will have to adjust the table and the records will be copied in every client, you will have to create and execute a small cleanup program
    Third step
    MANDT K
    VBELN K
    TAXINVNUM K
    KUNNR
    NAME
    Regards,
    Raymond

  • Auto_increment issue faced with primary key

    create table test(
    snum int not null auto_increment,
    course_id varchar(15),
    primary key(course_id, snum))
    create table testt(
    course_id varchar(15),
    pre_id varchar(15),
    foreign key (course_id) references test(course_id),
    foreign key (pre_id) references test(course_id))
    the above two table test has a primary key (snum, course_id) . course_id, which is being referenced in below table testt as a foreign key.
    i have an issue when trying to create a table test wit primary key (course_id, snum) that Error code 1075, SQL state 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key. but when place primary key(snum, course_id) it's working in this case i wasn't able to use course_id as foreign key for below table testt.
    could you please suggest me how to resolve this issue.

    The description of this forum is "Discussion of Oracle SQL and PL/SQL issues "
    MySQL Forums are at http://forums.mysql.com/
    Hemant K Chitale
    Edited by: Hemant K Chitale on Jan 11, 2011 2:56 PM

  • APEX 4.0 -Show and able to change Primary key values for Detail

    In a Master-Detail form, is there anyway I can show and able to change/select my primary keys from a select list field? One of my primary keys on the Detail is also primary key from another table which restricts my values for this field. I was able to show the fields but I can not make changes to this field and save the changes. Is there anyway I can have both show the field and able to change field's value and save it? Please advice. Thank you very much for your help in advance.
    -Grace

    Yes AFAIK Apex (for better or worse) was designed such that the PKs are generated automatically with PL/SQL, by a trigger, or whatever other algorithm that isn't in the control of the end user. It also only seems to allow a composite PK of no more than two columns.
    My usual strategy is to:
    1. Define the PK as a number (some sort of RECORD_ID, RECORD_SEQ, whatever) and populate it via a trigger on-insert.
    2. Define the "business" PK as a separate unique index. This way the user can set and modify it to their heart's content and it also isn't limited to just two columns (if the composite key's business requirement is such that more than two columns are needed).

  • JCA DB Adapter - merge - changing Primary Key

    Hello,
    I have an OSB business service that does a merge operation using a JCA DB Adapter. I recently changed the primary key of the table it's merging into, so also changed the toplink file of the business service (manually via sbconsole).
    However, in certain conditions, I'm getting an ORA-00001 error (JCA-11616). i.e. the merge is trying to do an insert that the violates primary key of the table.
    Should I have also made a change to something other than the business service? The table WSDL and XML don't mention the primary key as far as I can tell...
    Any ideas?
    Cheers

    That is probably a database error. If you changed the primary key of the toplink file to be less restrictive than the compound key in the database, you could potentially get this error. You need to make sure you have the primary keys or unique constraint columns from the database in the toplink file. You can then add additional columns to the toplink file based on your business logic, but never remove a database primary key from the file because the service could try a invalid insert.

  • Changing primary key(s)

    Is it possible to change the primary key of existing persistent objects at
    runtime? (If yes, are references from other tables updated automatically?)
    Regards
    Achim

    Hi,
    AFAIK, Kodo JDO 3.0.1 doesn't support the JDO optional feature:
    javax.jdo.option.ChangeApplicationIdentity
    So assuming you are using Application Identity for your class then you won't
    be able to change the fields that are part of the primary key.
    Not sure if that's what you meant?
    Cheers
    - Keiron
    "Hans-Joachim Oehme" <[email protected]> wrote in message
    news:bujkqd$2bt$[email protected]..
    Is it possible to change the primary key of existing persistent objects at
    runtime? (If yes, are references from other tables updated automatically?)
    Regards
    Achim

  • How to change primary keys of existing InfoCube.

    Greetings everyone!
    I’m trying to change the Key Fields in my reporting architecture as per our new company mandate.  I’ve been able to successfully change the primary keys for DS, DSO and InfoSource.  Can any kind soul out there please tell me how to change the primary keys on an existing InfoCube?  I will surely appreciate all the assistance I can get.  Its kinda urgent!
    Regards,
    Philips

    Hi,
    Check the possibility with Remodelling option . If it is not possible with Remodelling, then you can only change the cube deleting the Data.
    With rgds,
    Anil Kumar Sharma .P

  • Access issues while inserting data in a table in same schema

    Hi All.
    I have a script that at first creates and then populates a table. My script used to run fine in production environment till few hours back. But all of a sudden, it is popping up error while inserting data into the table .
    Error message - "Insufficient Previlages".
    Please suggest me what may be the reasons for this kind of error.
    Thanks in advance

    Sonika wrote:
    Hi All.
    I have a script that at first creates and then populates a table. My script used to run fine in production environment till few hours back. But all of a sudden, it is popping up error while inserting data into the table .
    Error message - "Insufficient Previlages".
    Please suggest me what may be the reasons for this kind of error.
    1) something changed
    2) you are hitting a bug

  • Issue while accessing a SQL Server table over OTG

    Hi,
    I have been learning oracle for about 1.5 years and am just starting to learn some OTG pieces. I am wondering about an issue. The issue is:
    "We need help with an issue we are having while accessing a SQL Server table over OTG. We are getting the following error message in Oracle :
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Oracle][ODBC SQL Server Driver]Unicode conversion failed {HY000}
    The column it is failing on is "-----------" in the view --------------- in the SQL Server database pointed to by the Oracle DB Link ------------------- thats created in the Oracle instances ---- and -----.
    This was working before, but is now failing, we suspect its due to new multi-byte data being added to the base table in the above column."
    I took out the details and added ---- instead. I am wondering your guys thoughts on fixing this issue and helping me learn along the way. Thanks

    Hi Mike,
    Thanks for the response, here are the details:
    1. What is the character set of the Oracle RDBMS being used. What is returned by -
    select * from nls_database_parameters;
    NLS_CHARACTERSET
    AL32UTF8
    NLS_NCHAR_CHARACTERSET
    UTF8
    We get SQL_Latin1_General_CP1_C1_AS and 1252 as Collation Property and Code Page
    The datatype of the column in question in SQL Server is nvarchar(100).
    When I do a describe on the SQL Server view ( desc CK_DATA_FOR_OPL@------- ), I get the error below;
    ERROR: object CK_DATA_FOR_OPL does not exist
    Select * from CK_DATA_FOR_OPL@------ where rownum =1 does get me a row.
    create table tmp_tab as
    Select * from CK_DATA_FOR_OPL@----- where rownum =1;
    desc tmp_tab shows the datatype of the said column in the table created in Oracle as NVARCHAR2(150).
    Not sure why a column defined with size 100 in SQL Server should come across as 150 when seen over OTG. We see something similar in DB2 tables we access over OTG as well.
    Edited by: 993950 on Mar 15, 2013 8:49 AM

  • Help with setting primary key in table

    Hi,
    I have created a table in Oracle and populated it with information, but I need a primary key (like an autonumber in Access) to identify each record. How can I do this for an existing table?
    Thanks so much for any help you can provide!

    Hello,
    I am assuming you have created the sequence and trigger i posted in my earlier post, here run this and if this answers your question mark post answered and reward points for helpful posts.
    INSERT INTO customer1 (FIRST_NAME,
                           LAST_NAME,
                           TITLE,
                           ADDRESS1,
                           ADDRESS2,
                           CITY,
                           STATE,
                           ZIP,
                           PHONE,
                           EXTENSION,
                           FAX,
                           WORK_PHONE,
                           WORK_EXTENSION,
                           MOBILE_PHONE,
                           EMERGENCY_PHONE,
                           PHONE_NOTES,
                           EMAIL)
       SELECT   FIRST_NAME,
                LAST_NAME,
                TITLE,
                ADDRESS1,
                ADDRESS2,
                CITY,
                STATE,
                ZIP,
                PHONE,
                EXTENSION,
                FAX,
                WORK_PHONE,
                WORK_EXTENSION,
                MOBILE_PHONE,
                EMERGENCY_PHONE,
                PHONE_NOTES,
                EMAIL
         FROM   CUSTOMER;
         COMMIT;Regards

Maybe you are looking for

  • ICal Problem with Mobile Account/Home and where are the calendars stored

    I am using MacMinis in an office with my MacPro SnowLeopard Server running LDAP with NetworkHome accounts. Almost everything works except this ical is driving me nuts. The problem is iCals don't sync with the NetworkHome. When I look in usr/library/c

  • Selection-Screen  - F4

    my requirement is <b>in my program i have 2 select-options 1.Company code (s_bukrs) 2.Portfolios (s_pfolio)</b> these two are maintained in a Ztable a)if we press F4 on Company code it has to show d values from Ztable-company code, and also b) i)if w

  • Accessing Dictionary devlopment component in Web dynpro component

    Hi I want to access a table created in the java dictionary development component in webdynpro. I dont want to use the EJB for doing this. Regards NagaKishore V

  • SQL Parsing Bug in Oracle SQL Analyze in 9i

    The following does not work in SQL Analyze on 9i: select extract(HOUR from to_TIMESTAMP('2003-02-28 13:00:00','YYYY-MM-DD HH24:MI:SS')) FROM DUAL; It complains at there being two "from" in the SQL. As I'm new to OTN is there a fix for this bug and is

  • How do I write a query to give back the records only with today's date?

    For example the date format is "2014-05-01 16:31:35.897" is a column called "EffectiveStartDate' I tried using where EffectiveStartDate like '2014-05-01%' but that returns nothing.