Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Temporary Tablespsace Temp tablespace behaviour Oracle
  • chk_space_SID.ksh Linux/Unix
  • dbms_job.submit example Oracle
  • Oracle Internal Good Websites 1 Oracle
  • Sort with ASCII order and Numeric Order Linux/Unix
  • Temporary Tablespace Information and restriction. Oracle
  • segment_wise_space.sql segspace.sql Segment wise space usage (allocated and used) Oracle
  • runsql_once.ksh Linux/Unix
  • tblwopk.sql tablewopk.sql Oracle
  • Find_planinfo.sql Oracle
  • Jai Shree Ram Oracle
  • ORA-3136 Oracle
  • To find all disk io ( EMC as well as local) Linux/Unix
  • In Addition to previous note, following grants needed on PERFSTAT user. Oracle
  • Good Link from metalink 1 Oracle

TRUNCATE table and disabling referential constraints.

Posted on 31-Mar-2006 By Admin No Comments on TRUNCATE table and disabling referential constraints.

When you truncate table A, and Table A has some child table that contain data. TRUNCATE fails. For that you need to find table A’s all child tables and diable that referential integrity.

/* before_trunc.sql

This script gives disble constrints script before truncating table

*/

accept tblname prompt ‘Enter the Table Name You want to truncate -> ‘

column head heading “Execute Following Statements To Truncate &tblname, as &tblname is referenced by following foreign keys”

select ‘alter table ‘ || lpad(b.table_name, 30) || ‘ disable constraint ‘ || b.constraint_name || ‘;’ as “Head”

from user_constraints a, user_constraints b

where a.constraint_name = b.r_constraint_name

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

Oracle, SQL scripts

Post navigation

Previous Post: Rownum with Order by
Next Post: before_trunc.sql Before Truncate table needs to execute following:

Related Posts

  • PLSQL Table Syntax 1 Oracle
  • How can I tell if ASO is installed ? Oracle
  • ORA-8031 issue and solution if it is occuring due to truncate. Oracle
  • create database link syntax Oracle
  • Proc code Oracle
  • Generating XML from SQLPLUS 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
  • Important Solaris Commands Linux/Unix
  • How to specify 2 arch location to avoid any kind of DB hanging. Oracle
  • How To Resolve Stranded DBA_2PC_PENDING Entries ID 401302.1 (Very Good prooven) Oracle
  • Jai Shree Ram Oracle
  • sid_wise_cursor.sql find open cursor basis on username or SID Oracle
  • Changing default shell Linux/Unix
  • How to find where datafile is created dbf_info.sql Oracle
  • CTAS with LONG Column for 9i and higher Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme