Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • create user with unlimited quota Oracle
  • Sending SQLPLUS output in HTML format Oracle
  • ipcs -l Linux/Unix
  • Oracle Metalink useful notes Oracle
  • Important Solaris Commands Linux/Unix
  • Giving Grant on v$DATABASE Oracle
  • grep multuple patterns Linux/Unix
  • V$ROLLSTAT status is Full Oracle
  • Test Case for Inserting Multiple (2.3 Million rows in 26 Seconds) Oracle
  • create trigger syntax Oracle
  • To see only files and/or folders using LS command Linux/Unix
  • Single character replacement in Unix Linux/Unix
  • eplan9i.sql Oracle
  • telnet listening Linux/Unix
  • fdisk -l explaination about Primary-Logical-Extended Partitions 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

  • Finding locked objects Oracle
  • 556976.1 Oracle Clusterware: Components installed Oracle
  • sql_doing_fts.sql Oracle
  • Oracle Metalink useful notes Oracle
  • GSQ.sql Oracle
  • Best approach for Oracle database patching sequence to latest/required patchset along with CPU/PSU/any-other-one-off patch ID 865255.1 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 (388)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (337)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • 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
  • Reading config file from other folder inside class24-Sep-2024
  • Python class import from different folders22-Sep-2024
  • Transfer SQL Profiles from One database to other database.05-Sep-2024
  • Load testing on Oracle 19C RAC with HammerDB18-Jan-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • To check whether standby is recovering properly or not?? Oracle
  • Absolute file number and relative file number Oracle
  • How to find where datafile is created dbf_info.sql Oracle
  • AWR settings- MMON is not taking snapshot. Oracle
  • cif crons Linux/Unix
  • Good Site for Oracle Internals Oracle
  • Find_planinfo.sql Oracle
  • RAC 11g with vmware Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme