OMPLUS retrieve table primary key column

I'm trying to retrieve the primary key column associated with a table via OMBPLUS.
The following command successfully returns the PK name
OMB+> OMBRETRIEVE TABLE 'ODS_REGION' GET PRIMARY_KEY
REGN_PKWhen I add the GET COLUMNS clause (as per API documentation), I'm still only getting the pk name.
OMB+> OMBRETRIEVE TABLE 'ODS_REGION' GET PRIMARY_KEY GET COLUMNS
REGN_PKAny suggestions on what I might be doing wrong?

Worked it out. Syntaxt needed is:
OMBRETRIEVE TABLE 'ODS_REGION' PRIMARY_KEY 'REGN_PK' GET COLUMNS
(no GET between table name and PRIMARY_KEY clause)

Similar Messages

  • How to know primary key column name form a table name in sql query

    Suppose I only know the table name. How to get its primary key column name from the table name?
    Thanks

    Views don't have primary keys though their underlying tables might. You'd need to pick apart the view to determine where it's columns are coming from.
    You can select the text of the view in question from user_views.

  • Knowing the primary key columns of the given table

    Hi,
    How can I get the primary key columns of the given table?
    Regards,
    Sachin R.K.

    You can find the constraint_name from all_constraints/user_constraints for constraint_type = 'P' (which is the primary key constraint).
    And then see which columns are in for the constriant_name
    in all_cons_columns/user_cons_columns view.
    Below is the example
    select acc.column_name from
    all_cons_columns acc, all_constraints ac
    where acc.constraint_name = ac.constraint_name
    and acc.table_name = 'DEPT' AND acc.owner = 'SCOTT'
    and ac.constraint_type = 'P'
    Hope this helps
    Srinivasa Medam

  • CDG-01141 ERROR: Module Component Table Usage ...  Table usage ... requires primary key column for referential integrity

    For some strange reason when I modified a form, (commented out some code in a when-window-activated trigger) I now get the following error.
    CDG-01141 ERROR: Module Component Table Usage GR1130A.CUSTOMER.GR_CUSTOMER.GC: Table usage GR_CUSTOMER requires primary key column for referential integrity
    I am sure this is not related to my change, but do not know what may have caused this or how to fix it.
    Anyone seen this error before? been able to fix it?
    Thanks!
    Windows 7
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Designer Version 6.5.95.4.8

    You know that Developer/Designer 6i is not certified for Windows 7, right? Also, your version is not the latest one, so you can try to install the latest patch set first.
    >Table usage GR_CUSTOMER requires primary key column for referential integrity
    Check if there is a PK in the table definition (not in the database, but in Designer).

  • Updation of table records having 5-6 primary key columns.

    I have a table structure having 12 primary composite keys.I have created report + form on this table.My requirement is to update the table by using form items fields.I am taking help of url option on report attribute page of application to fetch data on form page when we click on edit link of report page.Now i am having two problems which are as follows:-
    (i)I am unable to update data as requirement is to update 5 to 6 primary fields along with other non primary keys.I tried to create Pl/SQL process which will run update query but this process is not updating values.Is there any way that i could fetch data direct from database table in query rather then taking item values.Is there any other workaround?
    (ii)One of the primary key column contains records which have ' , ' in them .For ex:- cluth,bearing.So when i get navigated to edit page i am only getting text displayed as clutch i.e. text before ',' is getting displayed in text field while comma and the text after this is not getting displayed in text field of form page.
    Any solutions will be very helpful.
    Thanks
    Abhi

    Hello Abhi,
    >> I am unable to update data as requirement is to update 5 to 6 primary fields along with other non primary keys
    APEX wizards support a composite PK with up to 2 segments only. For every other scenario, you’ll have to manually create your DML code.
    If you have control over your data model, I would listen very carefully to Andre advices. Using a single segment PK is the best practice way. If you can’t add PK to your table, it seems that you’ll have to write your own DML code. The Object Browser option of creating a Package with methods on database table(s) can be a great help.
    >> … I am taking help of url option … One of the primary key column contains records which have ' , ' in them …
    Using the f?p notation, to pass a comma in an item value, you should enclose the characters with backslashes. For example,
    \cluth,bearing\In your case, it should be the item/column notation.
    http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/concept.htm#BCEDJBEH
    Regards,
    Arie.
    ♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    ♦ Author of Oracle Application Express 3.2 – The Essentials and More

  • Add primary key column to fact tables?

    Our datawarehouse folks asked me if they could add a primary key column in the BPC fact tables.  Anyone know if this is possible??
    Edited by: Shawn Freundschuh on Apr 3, 2009 12:27 PM

    Well.. based on my expeirence, it is not possible.
    When you run admin console, sometimes it will return error message.
    I tried it before but you can try it again. Maybe developer changed its behavior.
    Thanks.

  • Primary key column auto increment

    Hello,
    In my Azure SQL Database I noticed that weird thing is happening. I have table with primary key column with auto increment, and all works fine, on new insert that value automatically increment, but every now and then, that value, for no reason, increments
    for 1000.
    For instance i have in DB values in this order: 1, 2, 3, 4, 1001, 1002, 1003, 2004,  2005, 3001, 3002...
    Why is this happening? 

    Hello ,
    you can see this thread :
    http://stackoverflow.com/questions/17012339/windows-azure-sql-database-identity-auto-increment-column-skips-values
    It's seems that SQL Server work with sequence and block 1000 values. In the cloud, your SQL Azure Database can be move from one server to an other or restarted and so a new sequence is used. That's why you jump from 4 to 1001.
    Regards

  • FillSchema picks too many primary key columns

    I don't know whether this is an ODP.NET error or a Microsoft error.
    Oracle9i Release 9.2.0.1.0
    ODP.NET 9.2.0.4
    .NET Framework 1.1
    Create a table with one primary key column and one unique column and name the primary key column like the unique column with the suffix "_ID":
    CREATE TABLE t_bib_uebertrag_kap(
    &nbsp kapazitaet_id NUMBER(8) NOT NULL
    &nbsp&nbsp CONSTRAINT pk_kapa primary key,
    &nbsp kapazitaet VARCHAR2(15) NOT NULL
    &nbsp&nbsp CONSTRAINT a_un_kapa unique,
    &nbsp geschwindigkeit NUMBER(12) NOT NULL,
    &nbsp bemerkung VARCHAR2(255)
    After calling FillSchema on this table the PrimaryKey property of the DataTable contains 2 columns: KAPAZITAET_ID and KAPAZITAET.
    The same happens with other tables and similar column names
    R. Lüthke

    Tony, I'm gonna find time to try this because I was thinking it probably would be a double check.
    BUT... Oracle is written in C, and I imagine the extra check as a simple if comparison for the new value versus a constant NULL value. Kind of like checking for end of string. It's already doing things like checking datatypes and that as it inserts data, and I don't think this additional check (if it even exists) would add any significant overhead.
    But unless I find a much larger performance hit than I expect, I'm gonna stick with creating the NOT NULL's explicitly. Good data modelling trumps small performance tricks for me.
    My main worry is if/when somebody removes the primary key constraint (such as the example above where they might do a CREATE TABLE x AS SELECT * FROM y). Or if the data model gets updated to where the primary key becomes just a unique key, then the NOT NULL goes away when it shouldn't. I don't like basic table and column properties changing.
    Okay.. test done. Ran about 31,000 records from dba_tables through an insert into two tables, both with primary keys and one with explicit NOT NULLs. No measurable difference in stats detected.
    With NOT NULL and PRIMARY KEY:
    call count cpu elapsed disk query current rows
    Parse 1 0.35 0.35 0 0 0 0
    Execute 1 1.88 1.83 0 24792 35887 30954
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 2.24 2.18 0 24792 35887 30954
    Now with only PRIMARY KEY.
    call count cpu elapsed disk query current rows
    Parse 1 0.37 0.36 0 0 0 0
    Execute 1 1.87 1.83 0 24792 35887 30954
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 2.24 2.19 0 24792 35887 30954

  • Switch the sequence of Primary Key Columns

    Hi MaxDB experts,
    As part of our product upgrade we've made a schema change to 10 of our database tables. Typically these tables contain about 5 million rows in them. The change involves switching the order of columns in the primary key (original order SampleTime, Id; new order would be Id, SampleTime). What's the quickest way to achieve this?
    So far I've tried the following approaches without much luck:
    1. Use the "alter table alter primary key (new seuqence of columns)". Takes an average of 1 hour per table.
    2. Copy original table content into another table with "insert into newTable (select * from existingTable)" command. Takes the same amount of time as #1
    3. Tried using "Export Table" option presented by the "loadercli". Unfortunately, exported data can not be imported to a table with a different schema (in our case changed primary key column sequence).
    What else can we try? Any advise / direction would be greatly appreciated. Thanks for your time.
    Sincerely,
    Sameer Apte

    Hi there,
    ok, I assume that you figured out that you like to have data entries belonging to a specific ID stored rather nearby than scattered around in the table by TIMESTAMP or that you have more queries that specify the ID but not the TIMESTAMP.
    Both would be good reasons to perform such a change.
    Concerning the speed: basically things won't get any faster than ALTER TABLE or INSERT (SELECT * FROM)...
    The ALTER TABLE approach would have the advantage to be transactional atomic and simple to use.
    The INSERT approach would enable the use of the PREFETCHING feature for the read-I/O on the source table.
    So if you're just focussing on speed, then I'd recommend to:
    setup a data cache that can hold both source and target tables im memory
    enable prefetching by setting the parameter READAHEAD_TABLE_THRESHOLD to say 128 (be aware that you've to use MaxDB 7.6.05 or higher, but not 7.7.x  for that!)
    After you've copied each table, make sure to create the secondary indexes one by one since otherwise the internal parallelism won't be used.
    regards,
    Lars
    p.s.
    it is possible to export/import into different schemas - it's even supported via DB Studio.
    Anyhow, it wouldn't make anything quicker for this case.

  • Primary key column as the key of the cache

    Hi All,
    I am implementing a cache backed by HibernateCacheStore for a table. Cache contains key as the primary key of the table and value as the entire row in object format. the primary key is generated by hibernate.
    when i am inserting new rows through coherence (i.e cahce.put) what persistence strategy should is use to set the cache entries.
    I cannot use cache.put (key, value) because key is the primary key of the table which is not generated yet.
    and if i use the session.save(value) the persisted value is not in the cache.
    is there any mechanism to map the cache key as the primary key column of the table.
    Regards
    S

    Hi -
    Using Hibernate as a CacheStore for Coherence, the key of the cache entry is also the key of the entity
    being stored via Hibernate. For this reason keys for new cache entries must be generated ahead of time.
    A UUID can be used. The commons component of the Incubator project has a key generation utility that
    might be worth looking at.
    /Mark

  • Partition key on non primary key column

    I have scenario where the table has defined non primary key column as "partition key".
    I was wondering how it will affect the purge/archive process if the index and table are using different column (they are not aligned)?
    What should be the solution to this scenario?
    Can I use the non primary key column as partition key? Is this affect purging/archiving or switching -IN or OUT partitions?
    Here is the article which Im following but didn't get the precise answer:
    "When the indexes and the table use the same partitioning function and columns in the same order, the table and index
    are aligned." 
    https://msdn.microsoft.com/en-US/library/ms345146%28v=SQL.90%29.aspx?f=255&MSPPError=-2147217396#sql2k5parti_topic9
    Look at "Index
    Partitioning" and "Defining
    the Partitioning Key" section.
    ZK

    If it non aligned, you cannot do switching in or out.  to switch, you should have aligned partitons.
    Hope it Helps!!

  • TIPS(9):PARENT-CHILD(FOREIGN KEY) 관계를 갖는 MASTER TABLE의 PRIMARY KEY 확인.

    제품 : SQL*PLUS
    작성날짜 : 1996-10-21
    TIPS(9) : PARENT-CHILD관계를 갖는 TABLE의
    PRIMARY key, FOREIGN key의 COLUMN 명과 POSITION 확인
    ==============================================================
    ** Name : Show_Position.Sql
    ** Usage : @Show_Positions Parent_Table Child_Table
    ** Description : Shows Primary And Foreign Key Positions
    ** WARNING : 이 문장은 해당 Table의 Constraint생성시 Naming
    ** Convention을 따른 경우에 적용되도록 되어 있다.
    SET VERIFY OFF
    CLEAR BREAK
    BREAK ON CONSTRAINT_NAME ON TABLES
    SELECT SUBSTR(CONSTRAINT_NAME,1,27) CONSTRAINT_NAME,
    SUBSTR(TABLE_NAME,1,15) TABLES,
    SUBSTR(COLUMN_NAME,1,15) COL_NAME,
    SUBSTR(POSITION,1,3) POSITION,
    SUBSTR(OWNER,1,7) OWNER
    FROM USER_CONS_COLUMNS
    WHERE TABLE_NAME = UPPER('&1')
    AND CONSTRAINT_NAME LIKE 'PK%'
    UNION
    SELECT SUBSTR(CONSTRAINT_NAME,1,27) CONSTRAINT_NAME,
    SUBSTR(TABLE_NAME,1,15) TABLES,
    SUBSTR(COLUMN_NAME,1,25) COL_NAME,
    SUBSTR(POSITION,1,3) POSITION,
    SUBSTR(OWNER,1,7) OWNER
    FROM USER_CONS_COLUMNS
    WHERE TABLE_NAME = UPPER('&2')
    AND CONSTRAINT_NAME LIKE 'FK%'
    ORDER BY 1 DESC , 4 ASC;
    < 실행 예 >
    SQL> @SHOW_POSITIONS EMP_SERVICE EMP_SERVICE_LOG
    CONSTRAINT_NAME TABLES COL_NAME POS
    PK_EMP_SERVICE EMP_SERVICE EMP_ID 1
    CUST_ID 2
    FK_EMP_SERVICE_LOG_EC EMP_SERVICE_LOG EMP_ID 1
    CUST_ID 2

    제품 : SQL*PLUS
    작성날짜 : 1996-10-21
    TIPS(9) : PARENT-CHILD관계를 갖는 TABLE의
    PRIMARY key, FOREIGN key의 COLUMN 명과 POSITION 확인
    ==============================================================
    ** Name : Show_Position.Sql
    ** Usage : @Show_Positions Parent_Table Child_Table
    ** Description : Shows Primary And Foreign Key Positions
    ** WARNING : 이 문장은 해당 Table의 Constraint생성시 Naming
    ** Convention을 따른 경우에 적용되도록 되어 있다.
    SET VERIFY OFF
    CLEAR BREAK
    BREAK ON CONSTRAINT_NAME ON TABLES
    SELECT SUBSTR(CONSTRAINT_NAME,1,27) CONSTRAINT_NAME,
    SUBSTR(TABLE_NAME,1,15) TABLES,
    SUBSTR(COLUMN_NAME,1,15) COL_NAME,
    SUBSTR(POSITION,1,3) POSITION,
    SUBSTR(OWNER,1,7) OWNER
    FROM USER_CONS_COLUMNS
    WHERE TABLE_NAME = UPPER('&1')
    AND CONSTRAINT_NAME LIKE 'PK%'
    UNION
    SELECT SUBSTR(CONSTRAINT_NAME,1,27) CONSTRAINT_NAME,
    SUBSTR(TABLE_NAME,1,15) TABLES,
    SUBSTR(COLUMN_NAME,1,25) COL_NAME,
    SUBSTR(POSITION,1,3) POSITION,
    SUBSTR(OWNER,1,7) OWNER
    FROM USER_CONS_COLUMNS
    WHERE TABLE_NAME = UPPER('&2')
    AND CONSTRAINT_NAME LIKE 'FK%'
    ORDER BY 1 DESC , 4 ASC;
    < 실행 예 >
    SQL> @SHOW_POSITIONS EMP_SERVICE EMP_SERVICE_LOG
    CONSTRAINT_NAME TABLES COL_NAME POS
    PK_EMP_SERVICE EMP_SERVICE EMP_ID 1
    CUST_ID 2
    FK_EMP_SERVICE_LOG_EC EMP_SERVICE_LOG EMP_ID 1
    CUST_ID 2

  • 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

  • Ability to auto create a primary key column while creating an entity ?

    Product : oracle data modeler ( 3.0.0.665 32 bit version ) on windows XP Professional , : Target DB Oracle 11GR2
    I am new to Mozilla Rhino. Is it feasible to have a mechanism where in the primary key column name would be auto generated when the entity ( name ) is just created for the first time, and it has no columns defined yet . For e.g. one could create an entity named vendor , and after the table name is typed in, a column vendor identifier,of type numeric , is to be auto created. This mechanism should work even if the entity name changes, and the primary key is in format {tablename}_id , but it should not , if the primary key was manually set in later and is not in the expected format.

    I created this script (1) for adding an ID column (using a specific domain) to all supertype entities that do not already have an ID attribute, and a script (2) for adding primary key constraints to all ID attributes.
    - Marc de Oliveira
    Script 1:
    entities = model.getEntitySet().toArray();
    domain = model.getDesign().getDomainSet().getByName('Integer DIS Domain');
    for (var e = 0; e<entities.length;e++)
    entity = entities[e];
    if (entity.getHierarchicalParent()==null)
    attributes = entity.getAttributes().toArray(); // find existing attributes
    IDattribute = null;
    for (var a = 0; a<attributes.length; a++) // look for an ID attribute
    if (attributes[a].getName()=="ID") { IDattribute = attributes[a]; }
    if (IDattribute==null) // if an ID attribute was not found...
    IDattribute = entity.createAttribute(); // create a new ID attribute
    IDattribute.setName("ID");
    IDattribute.setDomain(domain);
    entity.moveToIndex(IDattribute,0); // move ID attribute to top
    Script 2:
    entities = model.getEntitySet().toArray();
    for (var e = 0; e<entities.length;e++)
    entity = entities[e];
    attributes = entity.getAttributes().toArray(); // find existing attributes
    IDattribute = null;
    for (var a = 0; a<attributes.length; a++) // look for an ID attribute
    if (attributes[a].getName()=="ID") { IDattribute = attributes[a];}
    if (IDattribute!=null) // if an ID attribute was found...
    key = entity.createCandidateKey(); // Create a key
    key.add(IDattribute); // Add the ID attribute to the key
    key.setPK(true); // Define the key as a primary key
    PKName = entity.getName().replace(" ","_")+"_PK";
    key.setName(PKName); // Define the key as a primary key
    entity.setPK(key); // workaround for bug...
    }

  • How to change (decrease) primary key column length?

    Hi all,
    I have plenty of data in the table and I need to decrease the primary key column from CHAR(17) to CHAR(13).
    I try to use:
    ALTER TABLE xx MODIFY (prmy_key (13));
    but Oracle give:
    ERROR at line 1:
    ORA-01441: column to be modified must be empty to decrease column length
    Can anyone give me advice on what is the best way to decrease column length? Thanks in advance for your help.

    To add to the above, I have done a simple test in the lines that I was suggesting the solution for this problem,
       CREATE TABLE testA
       (pk_col   varchar2(20), jd date, constraint pk1 PRIMARY KEY(pk_col));
       --Insert data into testA
       create table testB as select * from testA;
       TRUNCATE table testA;
       ALTER TABLE testA modify(pk_col VARCHAR2(10));   
       INSERT INTO testA SELECT substr(pk_col, 1, 10), jd from testB;
       DROP TABLE testB;
       Select constraint_name, constraint_type, status from all_constraints
       Where table_name = 'TESTA';
       CONSTRAINT_NAME                C STATUS
       PK1                            P ENABLEDAlter command is successful as the table is empty. TRUNCATE flushes the data and resets the high water mark keeping all the constraints. If we safely want to use the TRUNCATE as far as storage issues are concerned,
    TRUNCATE table table_name reuse storage;
    I think, this would accoplish what has been asked.
    Let me know,
    SriDHAR

Maybe you are looking for