Skip site navigation (1) Skip section navigation (2)

Alter Table Auto_Increment

From: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Alter Table Auto_Increment
Date: 2010-09-20 13:53:34
Message-ID: AANLkTinR9t3aYnTzLK=uzW3Gx02aQY8RGkL2DbFWoQTV@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
I have a table in my database and would like to modify the one column
that is already configured to be the PRIMARY KEY but I forgot to set
it for AUTO_INCREMENT. For some reason I can't find what the proper
command would be in the documentation and my commands from MySQL don't
appear to work properly in PostgreSQL:


sun=# \d blades
            Table "public.blades"
  Column  |         Type          | Modifiers
----------+-----------------------+-----------
 id       | integer               | not null
 ilom_ip  | character varying(15) |
 host_os  | character varying(50) |
 host_ip  | character varying(15) |
 hostname | character varying(50) |
 serial   | character varying(30) |
 gfe      | character varying(10) |
 admin    | character varying(50) |
Indexes:
    "blades_pkey" PRIMARY KEY, btree (id)

My command is not working so I don't know what I am doing wrong:

sun=# ALTER TABLE blades MODIFY int AUTO_INCREMENT;
ERROR:  syntax error at or near "MODIFY"
LINE 1: ALTER TABLE blades MODIFY int AUTO_INCREMENT;

Responses

pgsql-general by date

Next:From: Willy-Bas LoosDate: 2010-09-20 14:06:35
Subject: Re: where does postgres keep the query result until it is returned?
Previous:From: Ian BarwickDate: 2010-09-20 13:53:12
Subject: A note on pg_upgrade and missing "pg_upgrade_support.so"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group