Specifying a Default Value with DEFAULT

A default specifies a value that your DBMS assigns to a column if you omit a value for the column when inserting a row; see “Inserting Rows with INSERT” in Chapter 9. When you’re defining a default constraint, some important considerations are:

  • A default constraint always is a column constraint and not a table constraint; see “Understanding Constraints” earlier in this chapter.

  • You define a default constraint by using the keyword DEFAULT in a CREATE TABLE column definition.

  • A default value can be any expression that evaluates to a constant.

  • The default must have the same data type or must be implicitly convertible to the same type as its column; see “Converting Data Types with CAST()” in Chapter 5.

  • The column ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.