Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: How can we Empty the whole tables by one single query

Started 1 month, 2 weeks ago by lrsalunkhe
Respected, How can we truncate the whole tables value from my DataBase by single query. Thanks
Site: CodeProject: Discussion Boards. Free source code and programming help  CodeProject: Discussion Boards. Free source code and programming help - site profile
Forum: SQL / ADO / ADO.NET  SQL / ADO / ADO.NET - forum profile
Total authors: 7 authors
Total thread posts: 12 posts
Thread activity: no new posts during last week
Domain info for: codeproject.com

Other posts in this thread:

Niladri_Biswas replied 1 month, 2 weeks ago
truncate table tblName

David Mujica replied 1 month, 2 weeks ago
Drop database: The DROP DATABASE statement is used to delete a database. Everything is deleted ... tables, views, indexes, stored procedures, etc Drop Table: The DROP TABLE statement is used to delete a table. Truncate Table: Delete the data inside the table, and not the table itself Use this as reference: http://www.w3schools.com/SQl/sql_drop.asp [ ^ ]

lrsalunkhe replied 1 month, 2 weeks ago
Respected, But I have given the Relations to Tables. Thanks.

_Damian S_ replied 1 month, 2 weeks ago
Then do it one table at at time, starting from the leaf tables... eg: Persons have one or more Addresses. Delete Addresses first, then Persons.

Niladri_Biswas replied 1 month, 2 weeks ago
You could have specified that in the post.. How can one come to know that you want to perform a CASCADE DELETION ? e.g. CREATE TABLE tblPK ( id int primary key ) CREATE TABLE tblFK (id int , name varchar( 50 ), age int FOREIGN KEY (id) REFERENCES tblPK ON DELETE CASCADE )

Mycroft Holmes replied 1 month, 2 weeks ago
In 20+ years of database design and development I've never actually used cascade delete, I wonder why!

_Damian S_ replied 1 month, 2 weeks ago
Mycroft Holmes wrote: I wonder why! Because you are scared of it?

Mycroft Holmes replied 1 month, 2 weeks ago
I always envisage someone going to the settings table and using cascade delete on the Standard Customer record or something. Scared does not even cover it, terrified is closer.

_Damian S_ replied 1 month, 2 weeks ago
Meh... don't let users have access to the tables... have a good backup strategy!!

J4amieC replied 1 month, 2 weeks ago
Thats even the worst side effect. Imagine a header table with, lets say, 1000 records in it. Each header has 100,000 (badly indexed) child records. Cascade delete is turned on. Someone comes along and says "Ah header table only has 1000 rows, it will be easy to delete a record from there". Database reduced to treacle.

 

Top contributing authors

Name
Posts
_Damian S_
3
user's latest post:
How can we Empty the whole...
Published (2009-11-04 01:23:00)
Meh... don't let users have access to the tables... have a good backup strategy!!
lrsalunkhe
2
user's latest post:
How can we Empty the whole...
Published (2009-11-03 23:20:00)
Respected, But I have given the Relations to Tables. Thanks.
Niladri_Biswas
2
user's latest post:
How can we Empty the whole...
Published (2009-11-04 00:39:00)
You could have specified that in the post.. How can one come to know that you want to perform a CASCADE DELETION ? e.g. CREATE TABLE tblPK ( id int primary key ) CREATE TABLE tblFK (id int , name varchar( 50 ), age int FOREIGN KEY (id) REFERENCES tblPK ON DELETE CASCADE )
Mycroft Holmes
2
user's latest post:
How can we Empty the whole...
Published (2009-11-04 01:13:00)
I always envisage someone going to the settings table and using cascade delete on the Standard Customer record or something. Scared does not even cover it, terrified is closer.
David Mujica
1
user's latest post:
How can we Empty the whole...
Published (2009-11-03 04:40:00)
Drop database: The DROP DATABASE statement is used to delete a database. Everything is deleted ... tables, views, indexes, stored procedures, etc Drop Table: The DROP TABLE statement is used to delete a table. Truncate Table: Delete the data inside the table, and not the table itself Use this as reference: http://www.w3schools.com/SQl/sql_drop.asp [ ^ ]
J4amieC
1
user's latest post:
How can we Empty the whole...
Published (2009-11-04 05:52:00)
Thats even the worst side effect. Imagine a header table with, lets say, 1000 records in it. Each header has 100,000 (badly indexed) child records. Cascade delete is turned on. Someone comes along and says "Ah header table only has 1000 rows, it will be easy to delete a record from there". Database reduced to treacle.
Ashfield
1
user's latest post:
How can we Empty the whole...
Published (2009-11-04 13:31:00)
Probably for the same reason as I haven't - we are control freaks who like to explicitly delete things when we want to, not sudenly finding it happening 'on its own'

Related threads on "CodeProject: Discussion Boards. Free source code and programming help":

Related threads on other sites:

Thread profile page for "How can we Empty the whole tables by one single query" on http://www.codeproject.com. This report page is a snippet summary view from a single thread "How can we Empty the whole tables by one single query", located on the Message Board at http://www.codeproject.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity