test=#createtabletbl_inherits_partition2astabletbl_inherits_parentwithno data;SELECT0test=# \d tbl_inherits_partition2Table"public.tbl_inherits_partition2"Column|Type|Modifiers---+---+---a|integer|b|charactervarying(32)|c|integer|d|date|test=#select*fromtbl_inherits_partition2; a|b|c|d--...
EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [WHERE( predicate ) ] | FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE referential_act...
If you have successfully created the table, you can see the table you have created as shown below. Note: There are other options or variables available while you create a table, like setting primary or foreign key. But for the sake simplicity, we kept those options out of the scope of t...
CREATE TABLE orders ( order_id integer PRIMARY KEY, product_no integer REFERENCES products, quantity integer ); # 定义多个 Column 组成的外键,要求被约束列(外键)的数量和类型应该匹配被引用列(主键)的数量和类型。 CREATE TABLE t1 ( a integer PRIMARY KEY, b integer, c integer, FOREIGN KEY (b, ...
CREATE DATABASE postgres=# postgres=# postgres=# postgres=# \c test You are now connected to database "test" as user "postgres". test=# create table tbl_null (a int not null,b varchar(12)); CREATE TABLE test=# insert into tbl_null (a,b) values(1,'1'); ...
First, drop the sample tables and re-create them with the foreign key that uses the SET NULL action in the ON DELETE clause: DROP TABLE IF EXISTS contacts; DROP TABLE IF EXISTS customers; CREATE TABLE customers( customer_id INT GENERATED ALWAYS AS IDENTITY, customer_name VARCHAR(255) NOT ...
http://www.yiibai.com/manual/postgresql/sql-createtable.html 名称 CREATE TABLE -- 定义一个新表 语法 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name ( [ { column_name data_type [ DEFAULT default_expr ] [ column_constraint [ ... ] ] ...
通常一个表中的 FOREIGN KEY 指向另一个表中的 UNIQUE KEY(唯一约束的键),即维护了两个相关表之间的引用完整性。 实例 下面实例创建了一张 COMPANY6 表,并添加了5个字段: CREATE TABLE COMPANY6( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, ...
foreign key (scheme_id)references t_evaluation_scheme (id)on delete restrict on update restrict;';EXECUTE strSQL;---指定序列strSQL :='create sequence t_self_evaluation_'||currsnum||'_id_seq increment by 1minvalue 1 maxvalue 9223372036854775807 start with 1owned by t_self_evaluation_'||cu...
CREATE ROLE _name_ [ [ WITH ] _option_ [ ... ] ] where `_option_` can be: SUPERUSER | NOSUPERUSER | CREATEDB | NOCREATEDB | CREATEROLE | NOCREATEROLE ...CREATE RULE定义一个新重写规则。CREATE [ OR REPLACE ] RULE name AS ON event TO table [ WHERE condition ] DO [ ALSO | ...