Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

Code Block
languagesql
SELECT *
  FROM user_cons_columns
 WHERE table_name = '<table name>';

Get the primary key constraint name:

Code Block
languagesql
select constraint_name 
from dba_constraints 
where owner = '<SCHEMA_NAME>' and table_name = '<TABLE_NAME>' and constraint_type = 'P';

To check where the above primary key is used as a foreign key.

Code Block
select owner, table_name, constraint_name
from dba_constraints 
where r_constraint_name = '<result from previous query>' and constraint_type = 'R';


Run below query to give output as equivalent to `show create table <table name>` in MySQL.

...

Note: Before running query run set long 10000 command.

SQL to retrieve the blob value in text format in Oracle.

Example : Extract the form XML stored in the dyextn_containers table. 

Code Block
languagesql
select UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(XML, 2000,1)) form_xml from dyextn_containers where dbms_lob.instr (xml, utl_raw.cast_to_raw ('<form_name>'), 2000, 1) > 0;

Note: At a time we can only retrieve 2000 bytes only, 2000 is no of bites to print and 1 is offset. If someone wants to print data after 2000th byte replace 1 with 2001 next 2000 bytes will get printed.