Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In postgres how do I add index to existing table?

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);

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

 [echo] ERROR:  relation "my_index" already exists
like image 341
user1467855 Avatar asked Nov 15 '25 08:11

user1467855


1 Answers

Well, this error message:

ERROR: relation "my_index" already exists

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!