Global GuideLine Home HTML Tutorial JavaScript Tutorial SQL Tutorial CSS Tutorial SEO Tutorial XML Tutorial XSLT Tutorial Articles Tutorial Interview Questions and Answers Guide Jobs GuideLine Bookmark With Google Bookmark With Yahoo Bookmark With FaceBook Bookmark With Live Follow @GlobalGuideLine on Twitter Bookmark Global GuideLine
SQL Truncate Table, SQL Tutorial, Global Guide Line Technology.
Bookmark this webpage. Bookmark: SQL Truncate Table, SQL Tutorial Global Guideline is UNITED STATES's favorite website

      Home                    

Basic SQL Guide.           
SQL Introduction.               
 What is Table?                  
 SQL Create Table.            
 SQL Insert Statement.      
 SQL Select Keyword.        
 SQL Order by clause.        
 SQL Count Statement.      
 SQL Group By Clause.      
 SQL Having Clause.          
 SQL Alias Tables.             
 SQL Join Tables.              
 SQL Outer Join.               
 SQL Update Statement.   
 SQL Delete Statement.    
 SQL Distinct Keyword.      
 SQL Where Keyword.       
 SQL And Or Keyword.      
 SQL In Keyword.              
 SQL Between Keyword.   
 SQL Like Keyword.          
 SQL Functions.                
 SQL Concatenate.           
 SQL Substrings.               
 SQL Trim Function.         
 SQL Constraints.              
 SQL Primary Key.            
 SQL Foreign Key.            
 SQL Cerate Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.
 SQL Summary.                

SQL Tutorial >> SQL Truncate Table.


     Back             Next     




Sometimes we wish to get rid of all the data in a table. Now SQL Tutorial will explain that one way of doing this is with SQL DROP TABLE command, which we saw in the last lesson of out SQL Tutorial. But what if we wish to simply get rid of the data only and not the entire table itself? For this, we can use the SQL TRUNCATE TABLE command.  With the help of this command we can make the table empty from its data only. 
The syntax for SQL TRUNCATE TABLE is as under

Syntax for SQL Truncate Table

TRUNCATE TABLE "table_name"

So, if we want to truncate the table of Employees that we created in SQL CREATE TABLE section of our SQL Tutorail, we simply type this below query,

Example of SQL Truncate Table

TRUNCATE TABLE Employees

If we try to TRUNCATE a table, and the table is have a relationship with other table like Employees_Salary with the constraint of SQL Foreign Key then we can't TRUNCATE the table with this SQL Truncate Table command, here we need to TRUNCATE the Employees_Salary table first because Employees_Salary is depending on it and that is having some records. That's why we need to TRUNCATE both tables and the sequence is to empty that table which is based on SQL Foreign Key or remove this constraint first. Then we can TRUNCATE any table with SQL Truncate statement.

     Back             Next     
 
In order to link this page as Reference, click on below text area and pres (CTRL-C) to copy the code in clipboard or pres right click then copy the following lines after that past into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code:

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright © 2005-2006 www.globalguideline.com All rights reserved. Join Global Guide Line community. 270 visitors are online now