下面的查询在postgre中非常有效,因为表中不允许重复索引,但在DB中允许重复索引。
sandbox=# create schema test;
CREATE SCHEMA
sandbox=# create table public.a (a_id integer not null);
CREATE TABLE
sandbox=# create table test.a (a_id integer not null);
CREATE TABLE
sandbox=# create index a_idx on public.a (a_id);
CREATE INDEX
sandbox=# create index a_idx on test.a (a_id);
CREATE INDEX
进行时会发生什么
DROP INDEX a_idx;
- 这两个索引都会被删除吗
- 我能写
DROP INDEX test.a.a_idx
吗 - 删除时如何查找索引
发生的情况取决于search_path
的设置。PostgreSQL依次在search_path
上搜索现有的模式,一旦找到该名称的索引,它就会删除索引并完成。
我可以写DROP INDEX test.a.a_idx吗?
索引与其表在同一架构中,因此它只是DROP INDEX test.a_idx
(如果您希望/需要覆盖search_path(