if I have 4 columns say id , name , address and zip and if I use query like - Insert into (name,id) Values ('suraj',8) then it will work ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

if I have 4 columns say id , name , address and zip and if I use query like - Insert into (name,id) Values ('suraj',8) then it will work ?

23rd Aug 2016, 5:38 PM
Suraj Pathak
Suraj Pathak - avatar
3 Answers
+ 5
It will work, as long as the columns Address and Zip allow Null values in the table definition, and you don't have any other constraints or restrictions (e.g. a foreign key).
23rd Aug 2016, 10:33 PM
Michael Skae
Michael Skae - avatar
+ 2
to supplement the excellent answer of michael: yes. The values that you didn't fill in (adress, zip) will be filled with NULL (or, given the fact you created your table this way, with different default values e.g. incremental values).
23rd Aug 2016, 11:33 PM
niels
+ 2
you can use either: ('suraj',8,'','') or ('suraj',8,'NULL,'NULL')
24th Aug 2016, 12:37 PM
Sayan Sen
Sayan Sen - avatar