Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Error Handling in Proc Oracle
  • Histogram Overview Oracle
  • Kernel Parameters for Solaris Linux/Unix
  • Nice notes on wait events 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
  • segment_wise_space.sql segspace.sql Segment wise space usage (allocated and used) Oracle
  • Running select from V$ views from remote server Linux/Unix
  • TNSNAMES entries details Oracle
  • Follwoing korn shell is used to move files from source folder to destination folder and gzip it in destination folder. mv_iotto.ksh Linux/Unix
  • How do I get Oracle to automatically start when my server boots up? Oracle
  • Jai Shree Ram Oracle
  • Flowers Resize datafiles Oracle
  • Find Multiple levels of object dependencies : depen.sql Oracle
  • How to check current redo log progress redo_progress.sql Oracle
  • checking redhat linux version Linux/Unix

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

  • Export Oracle data and Compress at same time Oracle
  • Composite Index creation tip from Vivek Oracle
  • Ports used by Oracle Software Oracle
  • Renaming the column name Oracle
  • To see how much time or progress of long transaction Oracle
  • Very Good Oralce Internal Tuning Book 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 (392)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • 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
  • MYSQL and Oracle Comparison for Oracle DBA24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Check Oracle installed products using one command Oracle
  • Oracle 11g Environment Setup Oracle
  • Remove duplicate rows from table Oracle
  • v$event_name Oracle
  • Convert multiple rows to single column Oracle
  • Important Script Method for tuning Oracle
  • Parallel DML Oracle
  • checking connectivity between two servers Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme