SQL INSERT without specifying columns. What happens?

Your prof was right – you should name the columns explicitly before naming the values.

In this case though the values will be inserted in the order that they appear in the table definition.

The problem with this is that if that order changes, or columns are removed or added (even if they are nullable), then the insert will break.

In terms of its usefulness, not that much in production code. If you’re hand coding a quick insert then it might just help save you typing all the column names out.

Leave a Comment