Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • 272332.1 CRS 10g Diagnostic Collection Guide Oracle
  • Locally Managed Tablespace and Dictionary managed tablespace (LMT-DMT) Oracle
  • JSON/XML Types in Oracle Oracle
  • move_arch_files.ksh Linux/Unix
  • Physical Standby switchover with session active Oracle
  • Monitor Long Running Job Oracle
  • logminer and my_lbu Oracle
  • ORA-8031 issue and solution if it is occuring due to truncate. Oracle
  • Good Oracle Architecture In Short and point to point Oracle
  • checking redhat linux version Linux/Unix
  • Multiple listeners Oracle
  • database trigger failing Oracle
  • refre.sql Oracle
  • online_bkup.sql Oracle
  • rm_backup_arch_file.ksh Linux/Unix

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

  • Difference between SYNC and AFFIRM Oracle
  • 272332.1 CRS 10g Diagnostic Collection Guide Oracle
  • 276434.1 Modifying the VIP or VIP Hostname of a 10g or 11g Oracle Clusterware Node Oracle
  • reset Sequence Oracle
  • Convert multiple rows to single column Oracle
  • Proc code 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
  • Temporary Tablespace Information and restriction. Oracle
  • Find_table_size.sql Oracle
  • Reclaim temp tablespace for oracle 8, 8i Oracle
  • Unix command for system configuration Linux/Unix
  • 10g oem configuration Oracle
  • GSQ.sql Oracle
  • TABLE SIZING WITH DB_BLOCK ARCHITECTURE Reference : Metalink note : 10640.1 Oracle
  • secure crt settings Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme