下载吧 - 绿色安全的游戏和软件下载中心

软件下载吧

当前位置:软件下载吧 > 技术开发 > 数据库 > PostgreSQL中enable、disable和validate外键约束的实例

PostgreSQL中enable、disable和validate外键约束的实例

时间:2024-02-08 11:17作者:下载吧人气:17

我就废话不多说了,大家还是直接看实例吧~

postgres=# create table t1(a int primary key,b text,c date);
CREATE TABLE
postgres=# create table t2(a int primary key,b int references t1(a),c text);
CREATE TABLE
postgres=# insert into t1 (a,b,c) values(1,’aa’,now());
INSERT 0 1
postgres=# insert into t1 (a,b,c) values(2,’bb’,now());
INSERT 0 1
postgres=# insert into t2 (a,b,c) values (1,1,’aa’);
INSERT 0 1
postgres=# insert into t2 (a,b,c) values (2,2,’aa’);
INSERT 0 1
postgres=# d t1
Table “public.t1”
Column | Type | Collation | Nullable | Default
——–+———+———–+———-+———
a | integer | | not null |
b | text | | |
c | date | | |
Indexes:
“t1_pkey” PRIMARY KEY, btree (a)
Referenced by:
TABLE “t2” CONSTRAINT “t2_b_fkey” FOREIGN KEY (b) REFERENCES t1(a)

postgres=# d t2
Table “public.t2”
Column | Type | Collation | Nullable | Default
——–+———+———–+———-+———
a | integer | | not null |
b | integer | | |
c | text | | |
Indexes:
“t2_pkey” PRIMARY KEY, btree (a)
Foreign-key constraints:
“t2_b_fkey” FOREIGN KEY (b) REFERENCES t1(a)

postgres=#

标签[db:关键字]

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

热门阅览

最新排行

公众号