GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Database  >  SQL Server
Go To First  |  Previous Question  |  Next Question 
 SQL Server  |  Question 23 of 94    Print  
What is the difference among "dropping a table”,” truncating a table" and deleting all records" from a table?

  
Total Answers and Comments: 13 Last Update: October 14, 2007     Asked by: Beena 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
September 20, 2005 05:41:38   #1  
rahultripathi Member Since: September 2005   Contribution: 22    

RE: What is the difference among "dropping a table, ...

 Dropping table the structure of table as will as row of table .

but truncate table delete all the row of table but structure of table remain same we can apply  where condition on it . delete work like truncate the table but we can apply where condition on it.  Truncate can't roll back delete can. 


 
Is this answer useful? Yes | No
November 10, 2005 15:37:48   #2  
High Octane Member Since: November 2005   Contribution: 3    

RE: What is the difference among "dropping a table, ...
Here is a more complete answer: "dropping a table removes the table definition from the schema of the database and, of course, all the data truncating a table" internally within the database 'marks' the table as empty and this is imporant: the deleted records are not recorded in the transaction log."deleting all records" removes the records from the table and records each deletion in the transaction log
 
Is this answer useful? Yes | No
November 10, 2005 15:38:13   #3  
High Octane Member Since: November 2005   Contribution: 3    

RE: What is the difference among "dropping a table, ...
Here is a more complete answer: "dropping a table removes the table definition from the schema of the database and, of course, all the data truncating a table" internally within the database 'marks' the table as empty and this is imporant: the deleted records are not recorded in the transaction log."deleting all records" removes the records from the table and records each deletion in the transaction log
 
Is this answer useful? Yes | No
January 02, 2006 06:08:42   #4  
starmile Member Since: December 2005   Contribution: 4    

RE: What is the difference among "dropping a table, ...

Dropping table deletes table definition and  records both

Delete commannd deletes all records but records all details in Transaction log file. 

Truncate Table provides some special features in addition to delete all records from table . like Delete trigger not fired when it executes, Reset table identity. only page deallocation details send to Transeaction logs


 
Is this answer useful? Yes | No
February 13, 2006 06:42:20   #5  
Prasad Meduri        

RE: What is the difference among "dropping a table, ...

DROP <Table>: Drops the table records and structure from the DB schema. Nothing else is leftout. Can't rollback. 

Truncate <Table>: Clears the records from the table but the table structure still remains. Can't roll back.

delete from <table>: deletes the rows based on the query or will delete all the rows if no "where" clause is given. Can roll back i.e deleted records can restored.

In the first two cases transaction log is not done, but with delete transaction log is created. So it consumes more time compared to the above two.

Correct me if i'm wrong


 
Is this answer useful? Yes | No
April 03, 2006 07:09:49   #6  
aruna        

RE: What is the difference among "dropping a table, ...

Dropping tje table means we are deleting both structure & data

Deleting the table means just we are deleting the data but not structure

truncate also same as delete.


 
Is this answer useful? Yes | No
April 04, 2006 18:57:10   #7  
rupeshpatel Member Since: April 2006   Contribution: 1    

RE: What is the difference among "dropping a table, ...
Dropping a table will drop the table schema from the database, there wont be any more record of that table.Deleting a row will delete row from certain table with entry in log file for every row deleted, which we can rollback., it will not reset identity value of identity columnTruncating a table will delete all the rows from the table, and will make only one entry in log file for deleting all the row, THAT ALSO WE CAN ROLL BACK. Also it will reset Identity value of the identity column.DIFFERENCE BETWEEN DELETE AND ROLLBACK IS THAT : in delete it will make one entry for each row to be deleted. while truncate will make only one entry for all the rows. in delete it will free all the datapages by deleting the contents of the data pages. while in truncate it will delete the pointer to those datapages for all deleted rows.Also we can not use truncate if we have column in that table, which is referenced in other table. But we can use delete if we provided cascade options while creating tables.
 
Is this answer useful? Yes | No
April 10, 2006 08:19:21   #8  
swathi        

can v apply where condition on delet table and truncate table.

can we apply where conditon on delete and truncate table.


 
Is this answer useful? Yes | No
April 21, 2006 05:48:59   #9  
narayanapv Member Since: April 2006   Contribution: 3    

RE: What is the difference among "dropping a table, ...

Hi,

As You have written like you can apply where condition on Truncate, but we can not apply where clause.  So, kindly be careful before posting any messages. 

Narayan


 
Is this answer useful? Yes | No
August 23, 2006 06:07:22   #10  
D.Aringan        

RE: What is the difference among "dropping a table, ...
Truncating a table is just remove all the records from the table.'where'  clause is not used in truncating a table and also we cannot rollback the table.In delete option we can use WHERE clause to delete the rows and also we can rollback the deleted table.
 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape