"constant"、"expression" 和 "sequence" 在 DEFAULT 子句中代表什么?
What do "constant", "expression", and "sequence" represent in a DEFAULT clause?
目前正在通过 Postico 创建我的 PostgreSQL 表,我在创建新列时遇到了这个字段。它被称为 DEFAULT
,其默认值为 no default
。不过,您可以 select constant
、expression
和 sequence
作为选项。
这些到底是什么意思?
CREATE TABLE
上的手册:
DEFAULT
default_expr
The DEFAULT
clause assigns a default data value for the column whose column definition it appears within. The value is any
variable-free expression (subqueries and cross-references to other
columns in the current table are not allowed). The data type of the
default expression must match the data type of the column.
The default expression will be used in any insert operation that does
not specify a value for the column. If there is no default for a
column, then the default is null.
constant
和 expression
现在应该清楚了。 sequence
是一项特殊功能,使其成为 serial
列:
- Creating a PostgreSQL sequence to a field (which is not the ID of the record)
页面上有更多详细信息:
目前正在通过 Postico 创建我的 PostgreSQL 表,我在创建新列时遇到了这个字段。它被称为 DEFAULT
,其默认值为 no default
。不过,您可以 select constant
、expression
和 sequence
作为选项。
这些到底是什么意思?
CREATE TABLE
上的手册:
DEFAULT
default_exprThe
DEFAULT
clause assigns a default data value for the column whose column definition it appears within. The value is any variable-free expression (subqueries and cross-references to other columns in the current table are not allowed). The data type of the default expression must match the data type of the column.The default expression will be used in any insert operation that does not specify a value for the column. If there is no default for a column, then the default is null.
constant
和 expression
现在应该清楚了。 sequence
是一项特殊功能,使其成为 serial
列:
- Creating a PostgreSQL sequence to a field (which is not the ID of the record)
页面上有更多详细信息