在postgres中,如何将索引添加到现有表中? [英] In postgres how do I add index to existing table?

查看:435
本文介绍了在postgres中,如何将索引添加到现有表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在postgres中,如何向现有表中添加索引?

In postgres how do I add index to existing table?

我尝试了以下操作,但没有用:

I tried following but it's not working:

CREATE INDEX my_index ON my_table USING btree(a_column);

,然后执行以下操作:

CREATE INDEX my_index ON my_table USING btree(a_column);

但都不起作用。

我是使用ant进行数据库迁移。当我执行 ant db-migrate-apply-postgresql 时,我不断收到错误消息

I am using ant to do a db migration. And when I do ant db-migrate-apply-postgresql I keep getting the error

 [echo] ERROR:  relation "my_index" already exists


推荐答案

好吧,此错误消息:


错误:关系 my_index已经存在

很清楚,不是吗。

您正在尝试创建一个index与现有索引或表的名称。
您需要使用其他名称。

You are trying to create an index with the name of an existing index or table. You need to use a different name.

这篇关于在postgres中,如何将索引添加到现有表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆