Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
create table missing_data(sno varchar(3)primary key,name varchar(15),designation char(10))

insert into missing_data values(1,'riz','SE'),(2,'sandy','SE'),(3,'sharein','SE'),(4,'chithu','SE'),(5,'flora','SE'),(6,'gayu','SD'),(7,'maha','SD'),(8,'moni','SD'),(9,'maddy','AE'),(10,'naz','AE')

select * from missing_data order by sno

delete from missing_data where name='gayu' 


What I have tried:

I had deleted name='gayu' in the above table and i want sno = 6 to appear on the table after delete with null values in the row without affecting sequence.. is that possible in sql table???
Posted
Updated 23-Feb-16 2:09am
Comments
dan!sh 23-Feb-16 0:57am    
Don't delete it. Rather when the application makes a delete call, just set the fields to null.
alia007 23-Feb-16 1:02am    
can u explain with an example??
He is saying not to delete the whole row rather just set field values to null.
alia007 23-Feb-16 1:24am    
thanks !!! I got it
dan!sh 23-Feb-16 1:29am    
Check this link. If all you want is to find missing sequence. If you want to implement audit trail kind of functionality, that's a totally different story.

1 solution

You don't ever want to reuse Ids. If you delete a row then that ID is gone and it is very bad practice to use it again. Instead, if you don't really want it deleted, add a field named deleted_time and store the time it is deleted. Then filter those out when retrieving your data.
 
Share this answer
 
Comments
alia007 24-Feb-16 0:04am    
I got your point Ryan.. Thanks a lot for helping me out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900