时间:2024-02-05 11:03作者:下载吧人气:23
今天更新两个SQL。是用来查询PG中,主表被子表引用的外键,或子表引用了哪个主表的主键。
废话不多说,直接上实验!
CentOS 7 + PG 10
创建两个实验表,test01为主表,test02为子表,test02引用test01中的id列。
test=# create table test01(
test(# id int primary key,
test(# col1 varchar(20)
test(# );
CREATE TABLE
test=# create table test02(
test(# id int primary key,
test(# test01_id int references test01(id),
test(# col1 varchar(20)
test(# );
CREATE TABLE
网友评论