Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Generating XML from SQLPLUS Oracle
  • cur_sql.sql Oracle
  • Jai Shree Ram PHP/MYSQL/Wordpress
  • sql_plan9i.sql Oracle
  • CPU Core related projections AWS
  • restarting network in linux Linux/Unix
  • find_log_switch.sql Find log switches in graphical manner Oracle
  • Oracle 10g Wait Model Oracle
  • Clean up Oracle
  • Oracle Metalink useful notes Oracle
  • CTAS with LONG Column for 7.x and 8 and 8i Oracle
  • How to start CRS manually Oracle
  • Sample WW22 listener.ora Oracle
  • Changing the Global Database Name Oracle
  • Rman Notes -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

  • perf_today.sql Oracle
  • import-export with multiple files Oracle
  • executing Function from SQLPLUS prompt Oracle
  • DBMS_Shared_pool pinning triggers Oracle
  • Drop database in Oracle 10g Oracle
  • find_cons.sql Oracle

Leave a Reply Cancel reply

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

Categories

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

Recent Posts

  • prepfiles.sh for step by step generating pending statistics files10-Mar-2026
  • tracksqltime.sql05-Mar-2026
  • Complete Git Tutorial for Beginners25-Dec-2025
  • Postgres DB user and OS user.25-Dec-2025
  • 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

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Rman Notes -1 Oracle
  • Resolving RMAN Hung Jobs Oracle
  • Add new columns in dataframe Python/PySpark
  • upload.html PHP/MYSQL/Wordpress
  • How to stop OCSSD Daemon Oracle
  • tuning commmand for cpu, ip and memory stats Linux/Unix
  • Composite Index creation tip from Vivek Oracle
  • Find Plan Hash value fphv.sql Oracle

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme