【发布时间】:2019-02-05 15:53:26
【问题描述】:
我正在制作如下表格:
CREATE TABLE creator.lists
(
_id bigserial PRIMARY KEY NOT NULL,
account_id bigint NOT NULL,
created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
display_name text DEFAULT '',
name text DEFAULT '',
extra jsonb,
FOREIGN KEY (account_id)
REFERENCES creator.accounts (_id)
ON DELETE CASCADE
);
但我收到此错误:
ERROR: relation "account_id_index" already exists
当我跑步时:
CREATE INDEX
account_id_index
ON
creator.lists
(
account_id
);
如何在外键上创建索引?我正在运行 v11.1
请注意,我之前也为另一个表运行过类似的命令:
CREATE INDEX
account_id_index
ON
creator.contacts
(
account_id
);
我不认为索引名称在表之间需要是唯一的?
【问题讨论】:
标签: database postgresql indexing namespaces