我有两个表,profiles
我cities
想在表中添加一个列city_id
作为profiles
外键并使其引用表id
中的列cities
。所以我运行以下代码:
alter table profiles add column city_id integer REFERENCES cities(id);
奇怪的是,当我查看profiles
DDL 表时,我看到以下内容:
FOREIGN KEY ("30") REFERENCES public.cities (id)
MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION
当我期望它是
FOREIGN KEY (city_id) REFERENCES public.cities (id)
MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION
我究竟做错了什么?