時間:2024-02-05 11:03作者:下載吧人氣:17
今天更新兩個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
網友評論