Is there anyway to insert data in column only in SQL? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Is there anyway to insert data in column only in SQL?

like after inserting a new column im sql can we add data only?

28th May 2018, 8:21 AM
Saumya Sharma
Saumya Sharma - avatar
1 Answer
+ 3
I am assuming you have SQL code to add a column Now it is empty and you want to fill it You could use a default value, and then remove the default if it won’t be applicable for future inserts ALTER myTable ADD myColOfCodes int not null DEFAULT 1 WITH VALUES if this is not an appropriate solution, an UPDATE statement should do the trick ALTER myTable ADD myColOfCodeS int null UPDATE myTable set myColOfCodeS =1 WHERE myColOfCodeS is null
29th May 2018, 7:52 AM
SQrL
SQrL - avatar