13 Dec 2017

Difference between delete and truncate in sql


Difference between delete and truncate in sql

create table tblstudents
(
std_id int,   
stdname varchar(30), 
age  tinyint,
gender char
)

query 2:  how to insert data into above table

insert tblstudents (std_id, stdname, age, gender)  values (1001, 'jeff',21, 'm')

insert tblstudents (std_id, stdname, age)  values (1002, 'john',null)


Delete  : To remove data from table.      
        
  Query:            delete from tblstudents



Truncate : to remove data from table. this is not logged by log file. 


Query:              Truncate table tblstudents



Drop    : To remove structure of table. 

Query:  drop table tblstudents



No comments:
Write comments

Popular Posts

Popular Posts

Translate

Total Pageviews