5 Fix incorrect use of "psql", improve title while being at it.
source | link

How to makepromote an existing index in psql ato primary key in PostgreSQL

I know how to make a primary key within a table, but how do I make an existing index a primary key? I'm trying to copy an existing table from one database to another. When I show the table, the index at the bottom is in this form:

"my_index" PRIMARY KEY, btree (column1, column2)

I have created the index with:

CREATE INDEX my_index ON my_table (column1, column2)

butBut I do not know how to make it the primary key.  ...

UPDATE: The version of my server is 8.3.3

How to make an index in psql a primary key

I know how to make a primary key within a table, but how do I make an index a primary key? I'm trying to copy an existing table from one database to another. When I show the table, the index at the bottom is in this form:

"my_index" PRIMARY KEY, btree (column1, column2)

I have created the index with:

CREATE INDEX my_index ON my_table (column1, column2)

but I do not know how to make it the primary key....

UPDATE: The version of my server is 8.3.3

How to promote an existing index to primary key in PostgreSQL

I know how to make a primary key within a table, but how do I make an existing index a primary key? I'm trying to copy an existing table from one database to another. When I show the table, the index at the bottom is in this form:

"my_index" PRIMARY KEY, btree (column1, column2)

I have created the index with:

CREATE INDEX my_index ON my_table (column1, column2)

But I do not know how to make it the primary key  ...

UPDATE: The version of my server is 8.3.3

    Notice removed Improve details by Community
    Bounty Ended with Craig Efrein's answer chosen by Community
4 added 46 characters in body
source | link

I know how to make a primary key within a table, but how do I make an index a primary key? I'm trying to copy an existing table from one database to another. When I show the table, the index at the bottom is in this form:

"my_index" PRIMARY KEY, btree (column1, column2)

I have created the index with:

CREATE INDEX my_index ON my_table (column1, column2)

but I do not know how to make it the primary key....

UPDATE: The version of my server is 8.3.3

I know how to make a primary key within a table, but how do I make an index a primary key? I'm trying to copy an existing table from one database to another. When I show the table, the index at the bottom is in this form:

"my_index" PRIMARY KEY, btree (column1, column2)

I have created the index with:

CREATE INDEX my_index ON my_table (column1, column2)

but I do not know how to make it the primary key....

I know how to make a primary key within a table, but how do I make an index a primary key? I'm trying to copy an existing table from one database to another. When I show the table, the index at the bottom is in this form:

"my_index" PRIMARY KEY, btree (column1, column2)

I have created the index with:

CREATE INDEX my_index ON my_table (column1, column2)

but I do not know how to make it the primary key....

UPDATE: The version of my server is 8.3.3

    Tweeted twitter.com/#!/StackDBAs/status/146868071699714048
3 edited tags
| link
    Notice added Improve details by WildBill
    Bounty Started worth 50 reputation by WildBill
2 Corrected : 'form one database to another' to 'from one database to another'; Corrected : 'When I show teh table the index at the bottom is of the form' to 'When I show the table, the index at the bottom is in this form'
source | link
1
source | link