Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Identical Dblink Issue… Oracle
  • Oracle Release Explaination Oracle
  • Goog notes on X$ tables Oracle
  • Adding Datafile on Primary Server and Impact on Standby Server Oracle
  • Some OS level threshold for performance. Linux/Unix
  • Guide to Linux System Command Mastery Linux/Unix
  • Create type and Grant on it. Oracle
  • database trigger failing Oracle
  • Rollback force for distributed transactions Oracle
  • Transfer SQL Profiles from One database to other database. Oracle
  • Set Role explaination. Oracle
  • How to see which patches are applied. Oracle
  • Library cahe Latches and internal explaination Oracle
  • Creating never expiring DB user accounts in Oracle Oracle
  • Oracle 10g Installation/Applying Patches Tips Oracle

find_cons.sql

Posted on 02-Aug-2005 By Admin No Comments on find_cons.sql

set pagesize 300

set linesize 130

set head on

set echo off

accept tab prompt “Enter The Table Name -> ”

select b.constraint_name “Cons Name”, b.status,

decode(b.constraint_type, ‘P’, ‘PRIMARY’, ‘C’, ‘CHECK’, ‘U’, ‘UNIQUE’, ‘R’, ‘FOREIGN KEY’) “Cons Type”,

substr(a.column_name, 1, 20) “Column Name”,

decode(b.constraint_type, ‘C’, ‘ MUST NOT BE NULL’ , ‘ Position : ‘) ||

decode(b.constraint_type, ‘C’, null, to_char(a.position) ) ||

decode (b.constraint_type, ‘R’, ‘ REFERENCES ‘, NULL) ||

decode (b.constraint_type, ‘R’, c.xparent , NULL) “Cons Description”

from user_cons_columns a, user_constraints b,

(select parent.table_name xparent, child.table_name xchild, child.constraint_name xcons

from user_constraints parent, user_constraints child

where parent.constraint_name = child.r_constraint_name) c

where b.table_name = upper(‘&TAB’)

and a.constraint_name = b.constraint_name

and a.constraint_name = c.xcons(+)

order by b.constraint_name, a.position;

set head off

select ‘AND THIS TABLE &tab IS PARENT TABLE OF FOLLOWING TABLES’ from dual;

set head on

select a.table_name parent, b.table_name child, b.constraint_name “Child Cons Name”, b.status

from user_constraints a, user_constraints b

where a.constraint_name = b.r_constraint_name

and a.table_name = upper(‘&tab’);

set head on

Oracle, SQL scripts

Post navigation

Previous Post: Explain Plan Output 2
Next Post: findobj.sql

Related Posts

  • findx.sql /* Find Indexes on specified USER.TABLE_NAME */ Oracle
  • RAC 11g with vmware Oracle
  • DETERMINING WHICH INSTANCE OWNS WHICH SHARED MEMORY & SEMAPHORE SEGMENTS Oracle
  • Restoring a user’s original password 1051962.101 Oracle
  • standard Monitoring – 1 Oracle
  • Oracle 11g RAC on OEL 5 and Vmware 2 Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • setting prompt display with .profile Linux/Unix
  • Convert multiple rows to single column Oracle
  • checking redhat linux version Linux/Unix
  • Gather Stats manually using DBMS_STATS after disabling DBMS_SCHEDULER jobs as previous entry Oracle
  • CTAS with LONG Column for 9i and higher Oracle
  • fkwoindex.sql /* Find FK without Index */ Oracle
  • 751131.1 New Article Error 2819 While Requesting a Systemstate Dump Oracle
  • Good Oracle Architecture In Short and point to point Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme