時(shí)間:2024-02-05 11:03作者:下載吧人氣:21
今天更新兩個(gè)SQL。是用來查詢PG中,主表被子表引用的外鍵,或子表引用了哪個(gè)主表的主鍵。
廢話不多說,直接上實(shí)驗(yàn)!
CentOS 7 + PG 10
創(chuàng)建兩個(gè)實(shí)驗(yàn)表,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
網(wǎng)友評論