To define a foreign key, you can use a foreign key constraint. PostgreSQL foreign key constraint syntax The following illustrates a foreign key constraint syntax: [CONSTRAINT fk_name]FOREIGNKEY(fk_columns)REFERENCESparent_table(parent_key_columns)[ON DELETE delete_action][ON UPDATE update_action] ...
在PostgreSQL 中,我们使用 FOREIGN KEY 关键字来定义外键。外键通常和 REFERENCES 关键字配合使用。具体的语法如下:CREATE TABLE 表名 ( 列名 数据类型, ... CONSTRAINT 约束名 FOREIGN KEY (列名) REFERENCES 引用表名 (引用列名) [ON DELETE 动作] [ON UPDATE 动作] ); SQL Copy...
{ 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...
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 ...
42601 语法错误(SYNTAX ERROR) 42501 权限不够(INSUFFICIENT PRIVILEGE) 42846 无法进行类型转换(CANNOT COERCE) 42803 分组错误(GROUPING ERROR) 42830 非法的外键(INVALID FOREIGN KEY) 42602 非法名字(INVALID NAME) 42622 名字太长(NAME TOO LONG) 42939 保留名字(RESERVED NAME) 42804 数据类型不匹配(DATATYPE MI...
Syntax: CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name ( [ { column_name data_type [ STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT } ] [ COMPRESSION compression_method ] [ COLLATE collation ] [ column_constraint [ .....
表32. Class 42 — Syntax Error or Access Rule Violation Error Code Condition Name 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...
Syntax: [ WITH [ RECURSIVE ] with_query [, ...] ] SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ] [ * | expression [ [ AS ] output_name ] [, ...] ] [ FROM from_item [, ...] ] [ WHERE condition ] ...
创建触发器的语法如下 : Command: CREATE TRIGGER Description: define a new trigger Syntax: CREATE [ CONSTRAINT ] TRIGGER name { BEFORE | AFTER | INSTEAD OF } { event [ OR ... ] } ON table_name [ FROM referenced_table_name ] { NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | ...
postgres=# alter table testdb1 alter COLUMN parent_idtypeint USING parent_id::integer;ERROR:invalid input syntaxforinteger:"t" 但是这个时候发现,它给出提示,t是对于integer类型来说是一个错误的语法,说明我们刚刚插入的值是不能进行varchar到integer的转换的,我们将这个值删去,然后插入另外一个字符类型的数...