O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required