Is it possible to create many primary key for a table?

hello sir/mam.
i am selva, i am new to abap,
is it possible to create many primary key for a table?
please guide me.

Hi Selva,
Many Primary Keys = Composite Key.
i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
This can be achieved by checking the primary key check box in se11.
Hope it helps.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B

Similar Messages

  • How many primary keys for one table?can we add more primary keys

    In general Table have one  primary key.is it possible to more than one primary key in a table?(ie is it possible to add more than one pirmary key in a table). Help me out.

    pls do check this link
    [http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm]
    All the key fields of a table must be stored together at the beginning of the table. A non-key field may not occur between two key fields.
    A maximum of 16 key fields per table is permitted. The maximum length of the table key is 255.
    If the key length is greater than 120, there are restrictions when transporting table entries. The key can only be specified up to a maximum of 120 places in a transport. If the key is larger than 120, table entries must be transported generically.

  • How to create a foreign key for the table from two different tables?

    Hi All,
    I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
    code 1:
    CREATE TABLE SAMPLE_CONS_CHECK
            (NAME VARCHAR2(10),
            SERIES  VARCHAR2(5)
    CREATE TABLE SAMPLE_CONS2_CHECK
            (NAME  VARCHAR2(5),
             MODEL  NUMBER
    CREATE TABLE SAMPLE_CONS3_CHECK
            (NAME  VARCHAR2(5),
             MODEL_NO  NUMBER
            )code 2
    alter table SAMPLE_CONS_CHECK
    add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
    alter table SAMPLE_CONS2_CHECK
    add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
    alter table SAMPLE_CONS3_CHECK
    add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
    ALTER TABLE SAMPLE_CONS3_CHECK ADD
    CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
         NAME
    ) REFERENCES SAMPLE_CONS_CHECK
        NAME
    ) ON DELETE CASCADE;
    ALTER TABLE SAMPLE_CONS3_CHECK ADD
    CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
         NAME
    ) REFERENCES SAMPLE_CONS2_CHECK
        NAME
    ) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
    How can i solve this problem? Can anyone halp me about this?
    Thanks
    Edited by: orasuriya on Aug 8, 2009 2:02 AM

    Actually the design is completely incorrect.
    What you say is
    I have
    'foo', 'foo series'
    'foo','foo model'
    'foo',666
    By virtue of table3 referring to both table1 and table2.
    This means you actually need to have 1 (one) table:
    'foo','foo series','foo model', 666
    And the 'problem' disappears.
    Sybrand Bakker
    Senior Oracle DBA

  • How to define Composite primary key for a Table

    Hi ,
    I am basically more into Java Programming , with little bit knowledge on Oracle as DataBase .so please excuse for my silly doubts .
    Can anybody please tell me how to define a Composite Primary Key on a Table .
    Thanks in advance .
    Edited by: user672373773 on Sep 25, 2009 8:54 AM

    Here is an example right out of the Oracle documentation and the syntax for adding PK since you mention adding a composite PK.
    Example creating composite index
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_indexing.htm#sthref594
    Syntax for adding a PK (composite or not)
    alter table oooooooo.tttttttt
    add constraint tttttttt_PK
    primary key (sample_column2,
    sample_column1)
    using index
    tablespace IDXSPC
    pctfree 05
    initrans 04
    maxtrans 08
    storage (initial 16k
    next 16k
    maxextents 32
    pctincrease 0);
    -- dictionary management with restricted storage, change as desired.
    HTH -- Mark D Powell --

  • How add new field as primary key for existing table

    Hi,
    There is table with name REVIEWER_REUSE_EFFORT and the table has 8000 rows in it.
    Now the enhacement i must do on this table is there is no primary key on this table. so i must create a ID also add values to this table of ID
    Table structure is like this
    Create table REVIEWER_REUSE_EFFORT
    PRO_ID number,
    POBJ_ID number,
    TASK_ID number,
    POTENTIAL_EFFORT number,
    COMMENTS varchar2(1200),
    CREATED_BY varchar2(100),
    CREATION_DATE sysdate
    UPDATED_BY varchar2(1200),
    UPDATED_DATE sysdate
    Please suggest me how to add values in that 8000 rows
    Thanks
    Sudhir

    Hi,
    If you want to add a new column and update the new column with sequence of number
    alter table REVIEWER_REUSE_EFFORT add (ID number);
    update REVIEWER_REUSE_EFFORT  set ID=rownum;Regards,
    Prazy
    Edited by: Prazy on Jun 21, 2010 3:13 PM

  • How can I use the SQL to create a primary key for a existing table?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one? You do not have any primary key defined on your table yet, so, it does not make sense to enable it (if at all possible) !
    You need to add PRIMARY KEY using something like this:
    SQL> alter table a add constraint pk_a_bm primary key (bm) ;

  • How to create one primary key for each vendor

    Hi all
    i am doing IDOC to jdbc scenario
    i am triggering idoc from R/3 and the data is going into DB table vendor through XI.
    structures are as follows:
    sender side: ZVendorIdoc (this is a customized IDOC , if i triger IDOC for multiple vendors then it triggers only 1 idoc with multiple segment )
    Receiver side:
    DT_testVendor
        Table
            tblVendor
                action UPDATE_INSERT
                access                     1:unbounded
                    cVendorName         1
                    cVendorCode        1
                    fromdate                1
                    todate                    1
                 Key1
                    cVendorName         1
    if i trigger idoc for multiple vendors ,for example vendor 2005,2006 and 2010 . then i can see that the only key comes from the very first field (2005) and the whole record for vendor 2005,2006 and 2010  goes into the table with this(2005) as a primary key
    now again if i send data for these three vendor 2005, 2006 , 2010, in which record for the vendor 2005 is same and for 2006 and 2010 are different than it takes 2005 as a primary key and it does not update the data in the table.
    my requirement is like this:   for each vendor there should be one unique key assigned.
                                              for above said example there should come three keys one for each vendor .
    could you please help me how to do this???????????

    Hi,
      In Mapping Make the statement is 0-unbounded.For each vendor create a statement.This will solve your problem.
    Regards,
    Prakasu.M

  • Any easy way to generate unique primary key for database table?

    I'm currently playing with the J2EE reference implementation from Sun which comes with the IBM Cloudscape database. This Cloudscape database supports the use of an AutoIncrement field.
    First question: Can I use CMP and assume that the database will generate a proper key for me? Anyone tried it out successfully before?
    Also, based on what I've heard so far, it seems that generating database primary key is not really well-supported by J2EE using CMP in that a lot of J2EE developers have to resort to workarounds like using a session bean, JDBC and (1) some seed numbers for ID implanted in the database itself (as in the J2EE tutorial DukesBankApp example) or (2) using the SQL MAX aggregation command + 1. Usign seed number is contradictory to good database design and using MAX is dangerous for heavy traffic application if 2 beans try to insert themselves into the database at the same time (synchronizarion problem).
    Anyway I find it dumb that we still have to go back to JDBC and SQL which was the reason why the concept Entity Bean was introduced; to make database persistence transparent! Now it seems that J2EE makes it worse and more troublesome than before.
    Second Question: Is there any easy (hopefully transparent/automatic) way of generating primary key ID?

    if you want to rely on your container or database then go hard, will probably be faster.
    to make a cross container/db soln I used a CMP Entity bean called Sequence with one field for uid
    I use one instance and increment the field each time.
    To do the logic, I have a utils class with static method, no need for session bean overhead
    I reckon this approach is OK considering all things

  • Primary key for active table

    hi
    can anyone tell me step by step to create primarykey for active table of dso that already has data loaded. few requests are activated and few are not activated.
    points for sure.
    regards
    anil

    Anil,
    This is absolutely mandatory to delete the data from any of the table if you want to change the key fields of the table. This is as good as universal law in data base theory
    Now as far as your ODS is concerned, you have to delete the complete data from it and then you can change the key fields of it. Again you just need to change this in the definition of ODS and not in any particular table.
    Just change the definition of ODS in development and transport it to production. Make sure top delete the data before you transport it. If not, transport will fail.
    Hope this info helps you.
    Regards,
    Yogesh

  • How to create a primary key

    Hello - New to Oracle and was wondering what is a good way to create an auto-incrementing primary key for a table. I have done this so far:
    Created a new sequence cst_swq begin with 1 increment by 1.
    CREATE OR REPLACE TRIGGER CST_TRIG
    BEFORE INSERT
    ON COOKIE_SALES
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    SELECT CST_SEQ.nextval INTO NEW.SALE_ID FROM dual;
    This does not really work for me. Help with the code or a better idea to create primary key is much appreciated, thank you.

    adi26 wrote:
    This does not really work for me. What does that mean?
    In which way does this approch not meet your requirements?
    BTW: after 200+ posts you should have learned how to use tags...
    bye
    TPD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can I be able to create a primary key in a Form on a Table with Report?

    When I click the "Create" button, a form appears allowing me type in data for those columns. But primary key is not there. I really need to specify my primary key here also. Because the primary key for this table is a Serial Number, not just a sequence number.
    I noticed that when I created this page earlier, the primary key was ruled out by default. I wish there is a way to accomplish this. Thanks!

    Hello,
    >> a pk field is not null implicit …
    I’m not sure I understand your statement. Every item, including the one holds the primary key, is null for a new form. The question is, when you are filling the form, how to populate this field. The APEX wizard assumes this field will be populated by the system, hence it hides it from the user, however it’s a valid situation where the primary field is filled by the user.
    As primary field should not be changed, hence the productive advice by Martin. If the form displays an existing record, the primary field item should be set to Read Only.
    Regards,
    Arie.
    Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

  • Primary key for an column consisting duplicates

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

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

  • Primary key for table

    I have a table Gr_order which was populated ages ago and now it need to be populated
    with some more look up data.
    "Orderid" is primary key for the table but question is how do I insert "orderid" in insert statement in procedure. I could not find any sequence name. There are 1230
    records which need to be inserted.
    Desc Gr_order
    Orderid  Number Primary key
    Desc     Varchar2
    INSERT INTO gr_order (orderid,desc) 
    VALUES (???, upper(each_pom.desc);Thanks
    sandy

    You find the code that inserts into the table and see if it uses the sequence ;-) . A sequence is not "attached" to a particular table - it is up to the inserting statement to decide if a sequence is to be used.
    You might want to check if the table has a trigger - some developers like to emulate MS-sql server behaviour by having a trigger on the table that selects from a sequence. If it has such a trigger, then you just do your inserts without specifying order_id. But if the table does not have such a trigger, then you cannot know if the table was originally populated using a sequence or not (unless you can find the insert statements somewhere.)

  • How many primary keys can w have in cube, ods objects?

    how many primary keys can w have in cube, ods objects?

    Hi Naresh,
    16 primary keys only possible(for cube: 16 dimensions, ODS - Keyfields)
    For ODS:
    -         You can create a maximum of 16 key fields (if you have more key fields, you can combine fields using a routine for a key field (concatenate).)
    -         You can create a maximum of 749 fields
    -         You can use 1962 bytes (minus 44 bytes for the change log)
    -         You cannot include key figures as key fields
    More info: [Creating ODS Objects|http://help.sap.com/saphelp_nw04/helpdata/EN/4a/e71f39488fee0ce10000000a114084/content.htm]
    Hope it Helps
    Srini
    [Dont forget to close the call by assigning poings.... - Food for Points: Make a Difference through Community Contribution!|https://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/007928c5-c4ef-2a10-d9a3-8109ae621a82]

  • Can I create constraints "Primary key - Foreign key" on materialized views?

    Hello!
    Can I create constraints "Primary key - Foreign key" on materialized views like on tables?
    My purpose - is to make DB schema "COPY" with set of materialized views or tables, which take data from time to time from other tables situated.into another schema "ORIGINAL".
    Also - I want to use reporting tool, like Crystal Reports, to make nice reports from schema "COPY". To make nice reports, I need primary-foreign relationships between materialized views or tables in schema "COPY".
    Is it possible to use materialized views?
    Or I should use only tables to get such result?
    Thank you in advance.
    Edited by: kogotok1 on Dec 3, 2010 5:01 PM

    What happens when you try it? Or search the manuals.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6002.htm#i2105365
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#REPLN360

Maybe you are looking for

  • User is trying to acces t code S_ALR_87013611  Actual/Plan/Va Cost Center

    User is trying to acces t code S_ALR_87013611  Actual/Plan/Variance and is getting the error message. There are no changes done to the user role. The message comes as below : The report 'Cost Centers: Actual/Plan/Variance' is incomplete No authorizat

  • DOM Parsing Not working in Applet.

    Hi, I ve an applet (parserapplet)which contains the DOM parsing. So xalan.jar(nearly 780 kb) required to assist the parsing. I gave archive="xalan.jar" in My html file. But the jar file is not downloaded from the archive tag. and ClassnotFoundExcepti

  • Can I convert from pdf output into excellsheet in smartforms

    My smartform output is in pdf form now .Can i convert it into excellsheet by using save option. Moderator message: please do some own research before asking. Edited by: Thomas Zloch on Feb 21, 2011 12:49 PM

  • Help Requested. Have a BI Publisher requirement.

    Greetings! I need some help to go about in the right direction in creating some BI report template and emailing. I have oracle 11g DB, OBIEE and BI Publisher. I have a table in Oracle DB - Users The columns in the table are - First name,  last name,

  • How to stop Dragon Gaming Center's auto-start?

    Dragon Gaming Center is a good monitor, but i only want to start it before gaming. i cant find anything about Dragon Gaming Center in msconfig.exe and services.msc, but it already can auto-start. How to stop it?