Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert DEFAULT values

Is there ANY difference between those two statements?:

INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets');

and:

INSERT INTO distributors (dname) VALUES ('XYZ Widgets');

I mean is there at least one reason to use one or another pattern in some particular situation or is it completely the same? did is a serial column.

like image 509
Borys Avatar asked Jan 30 '13 11:01

Borys


1 Answers

It's exactly the same thing. No need to pick one instead of the other.

Usually default keyword is handy when you have computer-generated code. It makes life easier to just use every single column in the insert clause and just use default when you don't have a specific value for certain column.

Other than that, as I said, it's the same.

like image 139
Pablo Santa Cruz Avatar answered Oct 28 '22 12:10

Pablo Santa Cruz