Learning MySQL By Example
4.2

The INSERT Clause Without a Column List

The INSERT Clause Without a Column List

  • You can INSERT single or multiple rows at a time.
  • An INSERT without a column list requires you to provide a value for very column.
  • You must list values in the same order that they appear on the table.
  • You must explicitly use the keyword “null” for columns that allow for nulls if you do not want to provide a value.
  • You must explicitly use the keyword “DEFAULT” for columns that provide a default value if you do not want to provide one.

Code Sample:

1    USE world;
2    INSERT INTO city 
3    VALUES 
4        (DEFAULT, "San Felipe", "CHL", "Valparaiso", 64126);

Results:

iud_03.png

(DEFAULT "San Felipe", "CHL", "Valparaiso", 64126);

CC BY-NC-ND International 4.0

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.

End-of-Chapter Survey

: How would you rate the overall quality of this chapter?
  1. Very Low Quality
  2. Low Quality
  3. Moderate Quality
  4. High Quality
  5. Very High Quality
Comments will be automatically submitted when you navigate away from the page.
Like this? Endorse it!