Postgres-XC 0.9.7 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 5. Data Definition | Fast Forward | Next |
Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly.
A column can be assigned a default value. When a new row is created and no values are specified for some of the columns, those columns will be filled with their respective default values. A data manipulation command can also request explicitly that a column be set to its default value, without having to know what that value is. (Details about data manipulation commands are in Chapter 6.)
If no default value is declared explicitly, the default value is the null value. This usually makes sense because a null value can be considered to represent unknown data.
In a table definition, default values are listed after the column data type. For example:
CREATE TABLE products ( product_no integer, name text, price numeric DEFAULT 9.99 );
Note: The following description applies only to Postgres-XC
The default value can be an expression, which will be evaluated whenever the default value is inserted (not when the table is created). You cannot use STABLE or VOLATILE functions in this expression.