Полезная информация

next up previous contents index
Next: Column Labels Up: Customizing Queries Previous: Using NULL Values

Controlling DEFAULT Values

As we learned in the previous section, columns not specified in an INSERT statement are given NULL values. This can be changed using the DEFAULT keyword. When creating a table, next to each column type, you can use the keyword DEFAULT and then a value. The value will be used anytime the column value is not supplied in an INSERT. If no DEFAULT is defined, a NULL is used for the column. Figure [*] shows a typical use of default values. The default for the datetime type is actually a function call that returns the current date and time. Function calls are covered in section [*].

Figure: Using DEFAULTs
\par (1~row)\end{list}\par

If any values had been supplied for the default fields, those values would have been used instead.

Bruce Momjian