PostgreSQL foreign key constraint syntax The following illustrates a foreign key constraint syntax: [CONSTRAINT fk_name] FOREIGN KEY(fk_columns) REFERENCES parent_table(parent_key_columns) [ON DELETE delete_action] [ON UPDATE update_action] In this syntax: First, specify the name for the foreign...
在PostgreSQL 中,我们使用 FOREIGN KEY 关键字来定义外键。外键通常和 REFERENCES 关键字配合使用。具体的语法如下:CREATE TABLE 表名 ( 列名 数据类型, ... CONSTRAINT 约束名 FOREIGN KEY (列名) REFERENCES 引用表名 (引用列名) [ON DELETE 动作] [ON UPDATE 动作] ); SQL Copy...
42000 语法错误或者违反访问规则(SYNTAX ERROR OR ACCESS RULE VIOLATION) 42601 语法错误(SYNTAX ERROR) 42501 权限不够(INSUFFICIENT PRIVILEGE) 42846 无法进行类型转换(CANNOT COERCE) 42803 分组错误(GROUPING ERROR) 42830 非法的外键(INVALID FOREIGN KEY) 42602 非法名字(INVALID NAME) 42622 名字太长(NAME TOO ...
{ UNIQUE ( column_name [, ... ] ) [ USING INDEX TABLESPACE tablespace ] | PRIMARY KEY ( column_name [, ... ] ) [ USING INDEX TABLESPACE tablespace ] | CHECK ( expression ) | FOREIGN KEY ( column_name [, ... ] ) REFERENCES ref_table [ ( ref_column [, ... ] ) ] [ MAT...
Class 42 — Syntax Error or Access Rule Violation 42000 syntax_error_or_access_rule_violation 42601 syntax_error 42501 insufficient_privilege 42846 cannot_coerce 42803 grouping_error 42P20 windowing_error 42P19 invalid_recursion 42830 invalid_foreign_key 42602 invalid_name 42622 name_too_long 42939 ...
Syntax: CREATE TABLESPACE tablespace_name [OWNER{new_owner|CURRENT_ROLE|CURRENT_USER|SESSION_USER}] LOCATION'directory' [WITH(tablespace_option=value[,...])] URL:https://www.postgresql.org/docs/14/sql-createtablespace.html 示例: postgres=#CREATE TABLESPACE test LOCATION'/pgdb/data/test'; ...
postgres=# \helpSELECTCommand:SELECTDescription:retrieve rows from a table or viewSyntax:[WITH[RECURSIVE]with_query[,...]]SELECT[ALL|DISTINCT[ON(expression[,...])]][*|expression[[AS]output_name][,...]][FROMfrom_item[,...]][WHEREcondition][GROUPBYgrouping_element[,...]][HAVINGcondition...
{ "syntax_error_or_access_rule_violation", ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION }, { "syntax_error", ERRCODE_SYNTAX_ERROR }, { "insufficient_privilege", ERRCODE_INSUFFICIENT_PRIVILEGE }, { "cannot_coerce", ERRCODE_CANNOT_COERCE }, { "grouping_error", ERRCODE_GROUPING_ERROR }, {...
postgres=# \help SELECT Command: SELECT Description: retrieve rows from a table or view Syntax: [ WITH [ RECURSIVE ] with_query [, ...] ] SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ] [ * | expression [ [ AS ] output_name ] [, ...] ] [ FROM from_item [,...
More information about updating and deleting data is inChapter 6. Also see the description of foreign key constraint syntax in the reference documentation forCREATE TABLE.