How to see foreign key

Hello Expert:

In Oracle Enterprise manager - maintenance of the tables I see the primary key, another way to see foreign key related to another table.

Thanks in advance.

I don't know in EM, but you can always make something like the following in SQL * more...

select table_name from user_constraints where r_constraint_name = (select constraint_name from user_constraints where constraint_type = 'P');

You can then look at user_cons_columns to determine the actual columns in the constraint.

Another option is...

select dbms_metata.get_ddl('TABLE','TABLE_NAME','SCHEMA') from dual;

.. What would show constraints.

Tags: Database

Similar Questions

  • How did the foreign key that is recognized by the primary key

    Hi, when I have two user tables and userLevel and the primary key of the user is the user name and I add a field to userLevel userID is only to make the userID field in userLevel automatically the foreign key of the table? Or do you switch the engine of MyISAM tables to InnoDB to make relational links. Can someone please explain this in English clear to me, because I just can't get my head around this.

    In the case of a query such as SELECT statement, we talked, being a key actually means that the field is indexed so that the database can quickly look up.  Thus, in phpMyAdmin, you set the field to be indexed by the visualization of the structure of the table and clicking the icon index (the one with the Lightning) for the field in the Action section.

    If you are looking for integrity refrential between tables we also talked about and using the InnoDB engine, you can click the link 'Show the relational' in the table structure page of phpMyAdmin and define foreign key constraints.

  • 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:

  • How to associate an index with a foreign key constraint

    I understand how to associate a primary key constraint or a Unique key constraint index...
    Yet I don't see how to associate the index of a foreign key constraint. Is this possible?

    Thank you
    Bob Larsen

    Hi Bob,

    In Data Modeler, physical model for Oracle primary and unique keys dialog boxes offer an Index field using, which is used to generate the 'using_index_clause' in the DDL for primary and Unique key constraints.
    However the Oracle Database DDL does not have the "using_index_clause" for Foreign Key constraints, thus Data Modeler does not provide this feature for foreign keys.

    So, you will need to create a separate Index that uses the same columns as the foreign key (using the index page of the table properties dialog box in the relational model).

    David

  • How to check where the table field has been used as a foreign key in the database

    Hi I have a field in my table Office I had office_code field, this field has been used in the tables of diffirent as foreign key is a sql I can wirte to see all the tables that have used this field as a foreign key

    Edited by: adf009 09/05/2013 10:37

    Edited by: adf009 09/05/2013 10:38

    Check this box

    SELECT * FROM user_constraints WHERE table_name='EMP' and CONSTRAINT_TYPE='R';
    

    Type = 'R' means referential integrity constraint type.

  • How to make a primary foreign key?

    I'm working on my data model and I can't understand how a foreign key to be a primary foreign key... I'll make a primary foreign key for this specific table 2...
    I tried to do the foreign key checked as the primary_UID... but this isn't the solution... I want to show in the relational model indicated as "PF" or the primary foreign key

    Anyone know? Thanks in advance

    Hi Delos,

    What version of SQL Developer Data Modeler do you use?
    For me, it works in 3.1.1.703 and 3.1.2.704.
    Can you provide more details.
    For the logic model you can use the Unique identifier dialog box and add links to the list of used objects.

    Philippe

  • How to create a foreign key constraint on a table nested column

    Dear Experts,
    I create 2 tables using the object type. the VESSEL_PARAM table contains the list of the parameters allowed.
    The table VESSEL_TYPE containe single item we list some parameters.

    On this table, I love the column VESSEL_PARAM table VESSEL_PARAM to check if the settings are and the reference value is allowed.
    How to create a foreign key?
    Here my script that generates this runtime error: 00904. 00000 - '% s: invalid identifier' on this line

    ALTER TABLE VESSEL_PARAM_TAB ADD CONSTRAINT FK_VESSEL_TYPE FOREIGN KEY (NAME, DATA_VALUE)
    REFERENCES VESSEL_PARAM (PARAM_NAME, LIST_PARAM_VALUE. DATA_VALUE)
    CREATE OR REPLACE TYPE OBJ_PARAM_VALUE AS OBJECT 
    ( 
      DATA_VALUE  VARCHAR2(20)
     ,DESCRIPTION VARCHAR2(125)
    ) NOT FINAL;
    /
    
    CREATE OR REPLACE TYPE LIST_PARAM_VALUE AS TABLE OF OBJ_PARAM_VALUE;
    /
    
    -- derive object subtype from object supertype
    CREATE OR REPLACE TYPE OBJ_PARAM_NAME UNDER OBJ_PARAM_VALUE (
      NAME VARCHAR2(30)
    )NOT FINAL;
    /
    
    CREATE OR REPLACE TYPE LIST_PARAM_NAME AS TABLE OF OBJ_PARAM_NAME;
    /
    
    Prompt create table VESSEL_PARAM;
    CREATE TABLE VESSEL_PARAM (
       PARAM_NAME   VARCHAR2(20) NOT NULL
      ,PARAM_DESC   VARCHAR2(125)
      ,PARAM_VALUE  LIST_PARAM_VALUE
      ,CONSTRAINT PK_VESSEL_PARAM PRIMARY KEY (PARAM_NAME)
    ) 
    NESTED TABLE PARAM_VALUE STORE AS PARAM_VALUE_TAB
    TABLESPACE CMS_ADMDATA;
    /
    ALTER TABLE PARAM_VALUE_TAB ADD CONSTRAINT UN_PARAM_VALUE_TAB UNIQUE (DATA_VALUE);
    /
    SHOW ERROR;
    
    Prompt create table CMS_ADM.VESSEL_TYPE;
    CREATE TABLE CMS_ADM.VESSEL_TYPE (
      VESSEL_TYPE  VARCHAR2(20) NOT NULL
     ,VESSEL_DESC  VARCHAR2(125)
     ,VESSEL_PARAM LIST_PARAM_NAME
     ,CONSTRAINT PK_VESSEL_TYPE PRIMARY KEY (VESSEL_TYPE)
    -- ,CONSTRAINT FK_VESSEL_TYPE FOREIGN KEY (VESSEL_PARAM) 
    --        REFERENCES VESSEL_PARAM (PARAM_NAME)
    ) 
    NESTED TABLE VESSEL_PARAM STORE AS VESSEL_PARAM_TAB
    TABLESPACE CMS_ADMDATA;
    /
    ALTER TABLE VESSEL_PARAM_TAB ADD CONSTRAINT UN_VESSEL_PARAM_TAB UNIQUE (NAME);
    ALTER TABLE VESSEL_PARAM_TAB ADD CONSTRAINT FK_VESSEL_TYPE FOREIGN KEY (NAME,DATA_VALUE) 
            REFERENCES VESSEL_PARAM (PARAM_NAME,LIST_PARAM_VALUE.DATA_VALUE)
    /
    SHOW ERROR;
    Thank you

    Salvatore

    Could you please indicate your answer as correct if you judge them correct.

    Best regards

    Mohamed Houri

  • How can I get the data in the foreign key?  PHP/mysql

    I managed to create registration, log-in and results pages appear for accounts of client with PHP/Mysql/Dreamweaver 8. I have another page for more information to be contained in a child table, I used the Insert Wizard to create. I can't make it work. I get either a foreign key cannot be null error or a foreign key constraint.

    If I include the foreign key in the form on the page, I can manually enter the appropriate identification number, and it works. How to automatically enter the id into the foreign key column?

    I got the authentication of users using e-mail, password and user type.

    Thanks for your help

    When someone connects, Dreamweaver creates a session variable called $_SESSION ['MM_Username"]. Use this session variable to create a recordset object to get the ID of the user, who can then be entered in the child table's foreign key field.

    Dreamweaver automatically updates the code for recordsets immediately above the DOCTYPE declaration, then you will need to move above the code for the server behavior insert record. So it must be in the following order:

    1. Recordset to get the user ID
    2. Insert the record to the child table
  • Maker of SQL data - how to create the foreign key in the relationship 1 to 1?

    Hi guys...

    I had 2 tables...

    Table 1 - CFR
    -----------------------
    CFR_ID = primary key


    Table 2 - USER_PLAN
    ----------------------------
    User_id = primary key
    PLAN_ID ARGUMENT,
    CFR_ID = reference foreign key (table 1)


    Business flow go like this...
    table insdie CFR, it contains all the documents / transactions of a particular plan user. each time a new transaction occurs for a plan/user, a new CFR_ID / row will be generated.
    After that, the newly generated for the new line, CFR_ID will be updated to the CFR_ID in USER_PLAN


    Thus, there is always a 1 to 1 relationship between table 2, no matter how much CFR_ID is generated for a particular USER_PLAN. as the CFR_ID in the USEr_plan table will always be the last being produced within the table of the CFR.


    However, in the Data Modeler, I am unable to create this foreign key relationship... NO idea how create a 1 on 1 relationship of foreign key? or there is no way...


    Thank you and best regards,
    Noob

    Hey Noob,

    Yes, that's correct.

    Best regards
    Philippe

  • How knowledge column expression defined in the foreign key?

    Guys,

    How do I know what defined in the foreign key column expression?

    Thank you
    Hari

    Hello

    If you have permissions on this table, use all_cons_columns view.

    Kind regards

  • How to set the condition of rule to check the Primary Key, Foreign Key and Unique

    I use Oracle 10.2
    Could someone tell me please how to set the rule condition to check the primary key, foreign key constraint of uniqueness?

    Hello

    Primary key, unique constraints and foreign key are better applied using the native functionality of database constraint. If you like the rules to check if a key exists at the time of the evaluation, you can use a function defined by the user in a rule condition and this function can ask to turn the table keys.

    Hope this helps,
    -Aravind.

  • How to find the foreign key in pl/sql

    Error from the 1 in the command line:
    DELETE FROM ZKET_SOLE WHERE IID_SOLA = 1
    Error report:
    SQL error: ORA-02292: integrity constraint (IRCKIS. ZKETSTIP_ZKET_FK) violated - book of the foundling
    02292 00000 - 'constraint integrity (s.%s) violated - child notebook found. '
    * Cause: attempted to remove a parent key value that was a stranger
    dependence.
    * Action: remove dependencies first then the parent or disable the constraint.


    I need to find the foreign key, but I don't know how. I know it must be in the dictionary, but I'm not. I don't have access to the ER model.

    THX

    Run this query:

    select * from dba_constraints where owner = 'IRCKIS' and constraint_name = 'ZKETSTIP_ZKET_FK'
    
  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • How to find child every column foreign keys of tables without index {worm 10 g}

    Hi Experts,

    I have need of a query to find child all the foreign keys of table columns, which are not having an index on the foreign key column.

    Try this.

    SELECT T1. OWNER,

    T1. CONSTRAINT_NAME,

    T1. TABLE_NAME,

    T2. COLUMN_NAME,

    T1. CONSTRAINT_TYPE

    OF ALL_CONSTRAINTS T1,.

    ALL_CONS_COLUMNS T2

    WHERE T1. CONSTRAINT_NAME = T2. CONSTRAINT_NAME

    AND T1. TABLE_NAME = T2. TABLE-NAME

    AND T1. OWNER = T2. OWNER

    AND T1. CONSTRAINT_TYPE = 'R '.

    AND T2. COLUMN_NAME NOT IN (SELECT COLUMN_NAME FROM ALL_IND_COLUMNS T WHERE TABLE_NAME = T1.) TABLE_NAME AND COLUMN_NAME = T2. COLUMN_NAME);

    Post edited by: Parth272025

  • How to create a foreign key

    Hai

    I have two table

    Nrgp_main

    Nrgpno here is primary ky

    And NRGP_ITEM

    I need NRGPno as foreign key I dropped it and I now I need to recreate


    I have an error inIt


    ALTER table nrgp_item add constraint
    FK_NRGPITA foreign key (nrgpno) references nrgp_main (nrgpno);


    Error

    FK_NRGPITA foreign key (nrgpno) references nrgp_main (nrgpno)
    *

    ERROR on line 2:
    ORA-02270: no unique or primary key corresponding to this column list


    Concerning

    sRikkanth

    Hello

    You do something like that?

    SQL> create table a(n number primary key);
    
    Table created.
    
    SQL> create table b(n number);
    
    Table created.
    
    SQL> alter table b
      2  add constraint
      3  fk_n foreign key(n) references a(n);
    
    Table altered.
    
    SQL> alter table b
      2  drop constraint fk_n;
    
    Table altered.
    
    SQL> alter table b
      2  add constraint
      3  fk_n foreign key(n) references a(n);
    
    Table altered.
    

    Twinkle

Maybe you are looking for

  • Failed to save the Mac Pro Quad Core 10.8.5

    I recently installed Mountain Lion on a newly formatted on my Mac Pro Quad Core Intel Xeon desktop drive, installed all updates to 10.8.5 and now when I try to record on the 1 TB drive, says the disk is locked. When I try to copy files to the boot di

  • ATTENTION: lack of events in the event log

    I am slot as Vista Home Premium 64-bit. I have never received this warning before in a reliability and a report on the return, but three times today I received a warning that lack of events in the log. The percentage varies with each data collection.

  • How can I know my notebook\ ability?

    I want to upgrade to a newer version of windows, but I need to know if I have enough space to perform a custom installation, or if I need to buy a larger hard drive. How can I check my quality of notebooks? I have a hp mini 1030nr running windows xp

  • How to quit hanging out at Cavas in Photoshop

    There are times when I have an image open in Photoshop CS 5.5 which is going to be tabbed, which means it takes up the canvas of the entire program. If I then try to drag and drop an image on the desktop in Photoshop to work on it (unrelated to the f

  • SQL query to retrieve a single record for each employee of the following table?

    Hi allHelp me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.CREATE TABLE xxc_contact)empnum NUMBER,alternatecontact VARCHAR2 (100),relationship VARCHAR2 (10),phtype VARCHAR