Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Wait Based Tuning Step by step with SQL statement Oracle
  • To see only files and/or folders using LS command Linux/Unix
  • lck.sql Oracle
  • Order by with ROWNUM Oracle
  • Sequence Resetting Oracle
  • Logic to chech # of parameters command line parameters Linux/Unix
  • Does DBMS_JOB recompute the NEXT_DATE interval after or before Oracle
  • SQLPLUS COPY command Precautions. Oracle
  • Important Solaris Commands Linux/Unix
  • Good Oracle Architecture In Short and point to point Oracle
  • ORACLE_SID in sqlplus Oracle
  • RAC with RHEL4 and 11g Oracle
  • Distributed Transaction Troubleshooting. Oracle
  • chk_space_SID.ksh Linux/Unix
  • Identical Dblink Issue… 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

  • Insert cause enqueue locks Oracle
  • Multiple listeners Oracle
  • To find explain plan for a statement that occurred in past. Oracle
  • How to set Processes Parameter Oracle
  • ORA-1841 Error Connecting to Upgraded Database After Set PASSWORD_LIFE_TIME Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle

Leave a Reply Cancel reply

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

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (342)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • longtx.sql with the flag whether session is blocking any DML locks or not. Oracle
  • get_vmstat.ksh for Solaris Oracle
  • Oracle 10g Wait Model Oracle
  • Restoring a user’s original password 1051962.101 Oracle
  • Export Oracle data and Compress at same time Oracle
  • eplan.sql Oracle
  • CTAS with LONG Column for 7.x and 8 and 8i Oracle
  • Single character replacement in Unix Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme