postgresql 在 postgres 中如何向现有表添加索引?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11353347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In postgres how do I add index to existing table?
提问by user1467855
In postgres how do I add index to existing table?
在 postgres 中如何向现有表添加索引?
I tried following but it's not working:
我尝试了以下但它不起作用:
CREATE INDEX my_index ON my_table USING btree(a_column);
and then this:
然后这个:
CREATE INDEX my_index ON my_table USING btree(a_column);
But neither works.
但两者都不起作用。
I am using ant to do a db migration. And when I do ant db-migrate-apply-postgresql
I keep getting the error
我正在使用 ant 进行数据库迁移。当我这样做时,ant db-migrate-apply-postgresql
我不断收到错误消息
[echo] ERROR: relation "my_index" already exists
回答by a_horse_with_no_name
Well, this error message:
嗯,这个错误信息:
ERROR: relation "my_index" already exists
错误:关系“my_index”已经存在
is pretty clear, isn't it.
很清楚,不是吗。
You are trying to create an index with the name of an existing index or table. You need to use a different name.
您正在尝试使用现有索引或表的名称创建索引。您需要使用不同的名称。