hi,
i have a table which has child rows in another table. Now i want to truncate this
table temporally, because i will re-enter those values in a short time with some changes. cannot use update statement to make those changes. only possible way is truncating and inserting.
also i want to insert some data in to child rows without any parent rows. as in the previous section i can add the relevant parent rows shortly.
its like i want to ignore all the relations temporally while I’m performing this operation. After finishing it relations should work properly. it is 100% sure that the data is in the correct order to perform relations after i complete this operation.
Thank you,
Chathura Bamunusinghe
3 5436
hi,
i have a table which has child rows in another table. Now i want to truncate this
table temporally, because i will re-enter those values in a short time with some changes. cannot use update statement to make those changes. only possible way is truncating and inserting.
also i want to insert some data in to child rows without any parent rows. as in the previous section i can add the relevant parent rows shortly.
its like i want to ignore all the relations temporally while I’m performing this operation. After finishing it relations should work properly. it is 100% sure that the data is in the correct order to perform relations after i complete this operation.
Thank you,
Chathura Bamunusinghe
In case of primary key - foreign key relationship, you can disable the primary key of the table with CASCADE options. The cascase option will disable the refrential integrity constraints also. After disabling the constraints, you can perfomr TRUNCATE or DELETE/INSERT operations. Then you can ENABLE the constraints again
For disabling and enabling a constraint: -
-
ALTER TABLE table_name DISABLE PRIMARY KEY CASCADE;
-
-
ALTER TABLE table_name ENABLE PRIMARY KEY;
-
-
In case of primary key - foreign key relationship, you can disable the primary key of the table with CASCADE options. The cascase option will disable the refrential integrity constraints also. After disabling the constraints, you can perfomr TRUNCATE or DELETE/INSERT operations. Then you can ENABLE the constraints again
For disabling and enabling a constraint: -
-
ALTER TABLE table_name DISABLE PRIMARY KEY CASCADE;
-
-
ALTER TABLE table_name ENABLE PRIMARY KEY;
-
-
it was a good solution,
thanks a lot.
chathura bamunusinghe
it was a good solution,
thanks a lot.
chathura bamunusinghe
Hi,
You are Welcome!!
DO POST any issues in future, we will help you out!!
Regards,
Amit
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ed |
last post by:
I am trying to get some information to compare and contrast the
Truncate Table function and the Drop Table function. I know that
using Truncate Table is faster and saves the structure of the table...
|
by: martin |
last post by:
Hi,
We have a heavily used production server and a table which logs every
hit on a web site. This table has grown large over time and we want to
clear it down as efficiently as possible. We would...
|
by: LineVoltageHalogen |
last post by:
Greeting All, I have a stored proc that dynamically truncates all the
tables in my databases. I use a cursor and some dynamic sql for this:
......
create cursor
Loop through sysobjects and...
|
by: ronin 47th |
last post by:
Hi group,
In one of the books 'Gurus Guide to Transact SQL' i found this info:
------------------------------------------------------------
TRUNCATE TABLE empties a table without logging row...
|
by: rdraider |
last post by:
Hi,
I am trying to create a script that deletes transaction tables and leaves
master data like customer, vendors, inventory items, etc. How can I use
TRUNCATE TABLE with an Exists? My problem is...
|
by: Neil |
last post by:
Can one use Truncate Table on a linked server table? When I try it, I get a
message that only two prefixes are allowed. Here's what I'm using:
Truncate Table svrname.dbname.dbo.tablename
|
by: Sala |
last post by:
Hi
I want to truncate all data in database ... pls help me how i ll
truncate?
|
by: Troels Arvin |
last post by:
Hello,
Until this date, I believed that DB2 has no TRUNCATE TABLE command. But
then I came across...
|
by: Boogha |
last post by:
I have a cursor looping through a list of tables that I want to
truncate and then do a bulk insert into, Is this possible in SQL
Server 2000 or do script each table individually.
Cheers,
Adam
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |