Default Primary Key Field of any database table

hi,
I am working on a database in which the data in the tables is generated from some other modules. I have to add, view and update functionalities to this table in the database. Unfortunately there is no primary key field for the table i am working on and as some existing modules are using this table i am not allowed to change the design of the table at this stage.
Without primary i think its not possible to do updates. Because if all fields can have their values changed, then there will be a breakdown if the field value changes in the mid time when i had already retrieved the data to show on the screen, but not yet updated the value in the database. I hope you understood my problem.
Please suggest solutions. I am not sure, but i think i read somewhere that every table created has a default primary associated whose value is always incresing with a new addtion of recored and its value never decreases. But i am unable to recollect the field name...i think it is some thing like[b] OID .... But i checked there is no such field name by OID. So please help me with some alternative solution...or by telling the default primary key field name.
Thanx

All the databases I know (namely Informix, PostgreSQL, SQL Server, even Access) have a row id column generated automatically.
PostgreSQL example
There is a way to read the value of this column; for example with PostgreSQL let�s say you have the following:
CREATE TABLE no_id_column (
column_one varchar(80),
column_two varchar(80)
INSERT INTO no_id_column(column_one, column_two) VALUES (�red�, �pink�);
INSERT INTO no_id_column(column_one, column_two) VALUES (�yellow�, �orange�);Certainly, if we executed:
SELECT * FROM no_id_column;Would obtain:
column_one          column_two
red               pink
yellow               orangeBut if we modify the query
SELECT  oid, * FROM no_id_column;We magically obtain a row identificator
oid          column_one          column_two
21569          red               pink
21570          yellow               orangeThe data in the oid column is generated automatically by the database manager. Every time we insert a row we�ll have a different one. Just take into account that if the database contains a large amount of data, the oid could cycle.

Similar Messages

  • Adding 2 new fields as Primary Key field in a Z Table which is existing PRD

    Hi Friends,
    I have to add two new fields as primary key fields in a Z TABLE, which is existing in Quality and Production Systems with Data.
    If I incorporate these two new fields (Primary Key fields) in development and if the TR is moved to Quality and Production sytems, is there any possibility of loss in data will happen at Quality and Prd systems?
    At present, Table is having 20 fields with 2 primary key fields and i have to add 2 more primary key fields.
    I have checked in SCN and not find relevant threads.
    Please help me out.
    Regards,
    Suresh.

    NO . It wont be a problem .
    For ex :
    If you have VBELN  , POSNR are key fields now , you have an unique reord with that combination .
    If you add one other field in it  fo ex  VKBUR  then records will be like this
    VBELN     POSNR     VKBUR   MATERIAL   QTY
    10020      10                            abcxyz      1
    10020      10            1234        abcxyz     1
    So your previous records before adding new primary keys , will have new fields balnk , and the new records will have data filled up in all primary key fields .
    However , if you try to update the existing records that will be in existing PRIMARYKEY combination only .
    for example if you try update record 1 above with VKBUR value 85858 , it creates a new record , it wont be updated in existing record.
    Hope this helps , Pls let me know if u have any more doubts.

  • Creation of key field in a database table

    Hi All,
    As per my requirement, i have to add few new key fields in an existing table.
    Now total number of key fields are 17, but while saving this is giving me an syntax error stating 'According to SAA standard key fields cannot be more that 16'.
    I s there any other go? i can not reduce the number of key fields.
    Regards,
    Pankaj.
    Edited by: Pankaj Bist on Sep 5, 2008 3:24 PM

    Hi,
    In the se11 transaction,In the menu bar o like this.
    Utilites-->Database Utility and the Press the button Activate and Adjust Database.
    Note:
    Make sure that you total data in the table to be downloaded into ur system.
    As ctivate and Adjust Database makes data to be deleted.
    Regards,
    Rama.

  • How many primary key fields  allowed for one table?

    hi,
    when i creating a table , how many primary key fields are allowed for one table.
    please any one give ans
    thanks

    Just checked it,  Its 255, not 155.  You can have as many key fields as you want, but you can not go over the 255 byte length for the total of all key fields.  You will get a warning for over 120, as it says that there is limited functionality with a key over 120 in length.
    Again, this is a total length of all key fields.
    Regards,
    Rich Heilman

  • No of key fields in a database table

    hello experts,
    can anyone tell me what is the maximum number of keys we can have in a database table.
    thanks in advance

    Hi,
    There are two restrictions on the key fields while creating a table.
    1) The maximum number of keys in a table can be 16
    2) The maximum length of the key fields can be 120.
    Regards,
    Ferry Lianto

  • Concatenate Primary Key Fields of an internal table into a String.

    Hi,
    I have a dynamic internal table created.
    In the dynamic internal table,
    How to concatenate all the primary keys of that row concatenated into a string and non primary keys into a different string.
    Can some one help me on this.
    E.g:
    Itab1 has 3 Primary fields and 3 Non primary key fields and it has 2 records.
    Table     col1     col2     col3     col4     col5     col6
    Row1     AA     AB     AC     1     2     3
    Row2     ZA     ZB     ZC     1     2     3
    The following is needed.
    Itab2 will have the concatenate strings
                       Key                               Nkey
    Row1        AAABAC                      010203
    Row2        ZAZBZC                       010203
    Thanks,
    Chaithanya

    C,
    Try something like this -  Use an ASSIGN in a LOOP:
      data: lv_PK type string.
      data: lv_non_PK type string.
      field-symbols: lv_str type string.
      assign local copy of initial line of gt_table to <ls_table>.
      loop at gt_table.  " this is your table.
        do n times.  " n = 6 in your case
          if n < 4.
             assign component sy-index of structure <ls_table> to <lv_str>.
             concatenate <lv_str> to lv_PK.
       else.
             assign component sy-index of structure <ls_table> to <lv_str>.
             concatenate <lv_str> to lv_Non_PK.
         endif.
        enddo.
        append <ls_table> to <gt_table>.
      endloop.

  • How to find out the primary key column of a database table?

    Hi
    Given the following scenario :
    Given an inputfield, the user can enter a table name. The code behind will base on the table name given and extract out the fieldname of the primary key and concatenate the two field to become a unique string.
    Eg. Order ID and Product ID make out a primary key.
    How do i achieve that? Any code sample?
    Regards,
    Rayden

    Check the below code :
    REPORT zTest no standard page heading.
    data : i_DD03P like DD03P occurs 0 with header line.
    data v_table like DCOBJDEF-NAME.
    parameters : p_table like dd02l-tabname.
    start-of-selection.
    v_table = p_table.
    CALL FUNCTION 'BDL_DDIF_TABL_GET'
      EXPORTING
        NAME                = v_table
       STATE               = 'A'
       LANGU               = 'E'
    IMPORTING
      GOTSTATE            =
      DD02V_WA            =
      DD09L_WA            =
    TABLES
       DD03P_TAB           = i_DD03P
      DD05M_TAB           =
      DD08V_TAB           =
      DD12V_TAB           =
      DD17V_TAB           =
    EXCEPTIONS
       ILLEGAL_INPUT       = 1
       OTHERS              = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at i_DD03P.
    if i_dd03p-KEYFLAG = 'X'.
    write:/ 'Key fields', i_dd03p-FIELDNAME.
    endif.
    endloop.
    Thanks
    Seshu

  • Primary key deletion in custom database table

    hi,
        I've created a ztable.In which i've have created primary key and foreign key.
    I've activated the table.Now my requirement is that i want to delete the primary key as i've shoosen wrong field as primary key.
    For that first of all i deleted the foreign key relationship than i have unchecked the primary key but it is giving me an error.
    even though if i deleted that field having primary key it is also giving me error as "Primary key change not permitted for value table.
    Please help me out if possible.
    waiting for ur response.
    Thanks,
    Dheeraj

    Make sure u dont have any data in the table..u have to delete all the data..Also make sure you are not using that table any where else.do a where used list in the table.

  • Bank Key field change from database table

    Dear All,
    At our client, 4 house banks are maintained. The bank keys entered for these are not BSR Codes but something like 100,200,300,400.
    This is not correct as we need to maintain BSR Code in Bank Key field as it is required on Form 16 A (TDS Cetificate)
    The Bank Key field is in display mode. I am thinking of changing wrong value from database table T012 & BNKA .
    Has anybody done this before? Will it affect my past or future transactions?
    Thanks & regards,
    Gov

    Dear Gulshan,
    What you are saying is correct & I subscribe to your view also.
    Creation of House Bank all over again seems to be one of the better options.
    We tried doing one more thing & which is working fine on Development.
    Our primary requiremnt is to have BSR Code on the From 16 A. System picks up the Bank key for this.
    We copied the standard Form 16A & created a Z. Then abaper created a subroutine. It is like when Bank key 100 comes to Form16A, replace it with say 0098500 (Correct BSR Code of the Bank)
    This helped to get the correct BSR Code in Form 16A & saved us from recreation of House Bank data.
    Your comments are welcome.
    Regards,
    Gov

  • Regarding key field in a database table

    Hi friends, this is very urgent, plz help me.
    Here I have one field ex: MATNR , and I have to find out whether this field is key field or not in the MARA table. here the thing is I have to findout this programitically not going by SE11.
    Plz suggest me
    Regards
    Venkat.

    Hi prabhu,
    i think this is useful, but could you elaborate this little bit.
    regards
    Venkat

  • Problems deleting a primary key field in a table.

    Hello Guys,
    I deleted a primary key field in a custom table by clicking 'delete row' icon and then tried activating it through se14 - database utility. It is throwing an error saying 'Primary key change not permited for the value table zxxxx'. What is the problem???
    How can I delete a primary key in a table??
    Please help.
    Thanks,
    Naren

    I am pasting the detail explaination over that error.
    Primary key change not permitted for value table ZTV_RANGE_NUMBER
    Message no. AD 300
    Diagnosis
    This table is defined as a check table. For reasons of consistency, changes to the primary key of the table are not allowed.
    Procedure
    If it is essential that you change the primary key, you must delete the relevant foreign keys. Refer to the where-used list to find all tables containing a field that is checked against this table. Delete the foreign keys for these fields.
    If necessary, maintain the deleted foreign keys again.

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • Updation of Primary Key field in HR Tables (PA2001 and PA2002) - Urgent

    Can anyone please tell me how to update a primary key field in HR Tables (PA2001 and PA2002).
    I need to update sprps field in both the tables. I used HR_Infotype_Operation function module, but still it is not updating the field.
    Pls find the following code snippet for the table PA2001 and let me know if any discrepancies :
    TABLES: pa2001.
    DATA: it_pa2001 TYPE TABLE OF pa2001,
    wa_pa2001 LIKE LINE OF it_pa2001,
    DATA: date TYPE d.
    date = sy-datum - 100.
    SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
    WHERE begda BETWEEN date and sy-datum.
    WRITE:/.
    WRITE:/ 'PA 2001 Records'.
    if sy-subrc <> 0.
    WRITE:/ 'No Data Exists'.
    else.
    LOOP AT it_pa2001 INTO wa_pa2001.
    WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
    ENDLOOP.
    endif.
    LOOP AT it_pa2001 INTO wa_pa2001.
    wa_pa2001-sprps = 'X'.
    CALL FUNCTION 'HR_INFOTYPE_OPERATION'
    EXPORTING
    infty = '2001'
    number = wa_pa2001-pernr
    SUBTYPE =
    OBJECTID =
    LOCKINDICATOR =
    VALIDITYEND =
    VALIDITYBEGIN =
    RECORDNUMBER =
    record = wa_pa2001
    operation = 'MOD'
    TCLAS = 'A'
    DIALOG_MODE = '0'
    NOCOMMIT =
    VIEW_IDENTIFIER =
    SECONDARY_RECORD =
    IMPORTING
    RETURN =
    KEY =
    ENDLOOP.
    if sy-subrc = 0.
    write:/ 'SY-subrc is zero'.
    write:/ ' Rows modified = ', sy-dbcnt.
    else.
    write:/ 'No Record(s) updated'.
    endif.
    commit work.
    WRITE: / 'Updated Records in the Internal Table IT_PA2001'.
    SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
    WHERE begda BETWEEN date AND sy-datum..
    LOOP AT it_pa2001 INTO wa_pa2001.
    WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
    ENDLOOP.

    Thanks Kiran.
    But I need to change this field as we need to lock the records, as soon as the employee fills his/her time sheets which will be sent for HR Payroll, later on.
    When I am updating directly the field the database table PA2001, its not updating but for table PA2002, only few records are being updated.
    Is there any other alternative for this problem?
    Pls reply.
    Thanks,
    Harish

  • Setting primary key field value in jdoPrestore() not flushed to database ?BUG?

    Hello,
    When I set value of primary key field of a new instance in jdoPrestore() new
    value does not get flushed to database - old (default) value get stored
    instead. All other fields assigned in jdoPrestore() get successfully
    flushed except primary key one.
    Alex

    Abe,
    You fixed only part of the problem. Right now if I assign value to a PK
    field in jdoPreStore() it does get flushed but there is another issue - all
    other instances which referenced the one I assigned PK to will not get this
    PK value. Example A references B, in B.jdoPreStore() I generate id for B -
    b.id = 100. When A gets flushed it would not get 100 in its b_id field.
    Specs says:
    This method is called ***before the values are stored from the instance to
    the StateManager***.
    Data store fields that might have been affected by modified non-persistent
    fields should
    be updated in this method. This method is modified by the enhancer so that
    changes to
    persistent fields will be reflected in the data store.
    The context in which this call is made allows access to the
    PersistenceManager and
    other persistent JDO instances.
    I read it as callbacks should be invoked on ALL instances before they get
    stored to StateManager. Does Kodo invoke callbacks for all istances first
    and then store them to instance manager? Based on the problem I am having it
    does not look like it
    Alex
    "Abe White" <[email protected]> wrote in message
    news:[email protected]..
    I just confirmed this as a bug and fixed it. We should be able to post
    the new jars for you soon. Hang in there.

  • To modify a field in a database table based record identification by primar

    hi
    i want to to modify a field in a database table based record identification by primary key filed and two more fields
    ie customer (primary key
    i want to modify record from intenal table the record existing with primary key field customer
    the status field needs to be mofied as " value rolled"
    the below code is happening
    loop at it_record into wa_Record
    wa_inv-customer (primary key) = wa_Record=custome
    wa_inv-date = wa_Record-date
    ...so one
    append wa_inv to it_invest
    clear wa_inv
    endloop.
    if not it_invest  is initial
    modify TABle1 ( this table is data base table which needs to be mofified) based on the primary key field
    and also date field and status field which is not primary key.
    regards
    arora

    Hi there.
    Your requirement is to update a Z Database table from your internal table, right? You have several options:
    LOOP AT it_invest INTO wa_inv.
      UPDATE dbtable
         SET date = wa_inv-date
       WHERE prim_key = wa_inv-prim_key
         AND any_field = wa_inv-any_field.
    ENDLOOP.
    or
    LOOP AT it_invest INTO wa_inv.
      UPDATE dbtable FROM wa_inv. "if wa_inv of same type of dbtable
    ENDLOOP.
    In the first example, I wrote any field because you can update dbase table, filtering for fields that don't belong to the primary key. However, remember that you will change all records that respect the key you used (so, in your case, use the primary key).
    Regards.
    Valter Oliveira.

Maybe you are looking for

  • How to add a blank row in a report structure ?

    Hi, I have a report which uses a structure in both the rows and the columns. It also using cell definitions to define some cells in the report. What I want to do is to format the report a bit more and insert a blank line at various points in the row

  • Batch color conversion

    Have large number of book files in pdf format sent by a client. Other than the covers, all pages are grey, but they are in cmyk format. Our digital press will track those as color prints and we will be charged accordingly. I have Quite a Box of Trick

  • Firewire as startup disk

    I have a Lacie fire wire drive that has an image of older ibook(that has died) When I start my new intel based imac while holding down the option key it will not show the drive as a boot option, only the hd on the intel based iMac.

  • MSI CD-RW 48-A2 Burner

     ?(  I just bought this drive and it works ok , but it only burns cd's at 24x max and i have tried 3 different types of cd-r's and 2 different types of burning software. all being 48x. Also if i go to hardware manager it shows the drive being a gener

  • To store data as paragragh

    Hello, Is it possible to store in db(oracle 9i) a volume of data split into paragraphs as it is?Also, would I be able to retrive it with a select query in the same format that i stored it too. Ex: If this is the data, Hence Burgundy, Claret, and Port