displaying a table with PK first then FK?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mp01
    New Member
    • Dec 2009
    • 1

    displaying a table with PK first then FK?

    Is there a way to create a table that displays tables in order of table with PK first then tables with FK?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Kindly pass more information . I think you need to look into some dictionary views for the info.

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Try this query:

      [code=oracle]
      SELECT acc.table_name Table_Name,
      acc.constraint_ name Constraint_Name ,
      acc.column_name Column_Name,
      DECODE(ac.const raint_type,'P', 'Primary Key','R','Forei gn Key',ac.constra int_type) Constraint_Type ,
      ac.r_constraint _name Referred_Constr aint_Name,
      (SELECT DISTINCT table_name FROM all_constraints where constraint_name = ac.r_constraint _name) Reffered_Table_ name
      FROM
      all_cons_column s acc,all_constra ints ac
      WHERE
      acc.constraint_ name = ac.constraint_n ame
      AND ac.constraint_t ype IN ('P','R')
      ORDER BY
      acc.table_name, 4 DESC
      [/code]

      Comment

      Working...