Re: alter table - Mailing list pgsql-general

From Gregory Wood
Subject Re: alter table
Date
Msg-id 001701c179be$4075be90$7889ffcc@comstock.com
Whole thread Raw
In response to alter table  ("Yuri A. Kabaenkov" <sec@artofit.com>)
Responses Re: alter table
List pgsql-general
According to the documentation:

ALTER TABLE table [ * ] ADD [ COLUMN ] column type

Which means you can only set the column type of the new column. You'll have
to go back and alter that column to add a default:

ALTER TABLE table [ * ] ALTER [ COLUMN ] column { SET DEFAULT value | DROP
DEFAULT }

You'll no doubt also want to add that NOT NULL constraint:

ALTER TABLE table ADD table constraint definition

I know this only because it bit me in the ass the other day too :)

Greg

----- Original Message -----
From: "Yuri A. Kabaenkov" <sec@artofit.com>
To: <pgsql-general@postgresql.org>
Sent: Friday, November 30, 2001 10:22 AM
Subject: [GENERAL] alter table


> Hello,
>
>       I've read documentation on alter table syntax and doesn't find
>       anything about change column type or drop column.
>
>       Also when i add column by command
>       alter table test add column a integer not null default '10'
>
>       It adds column but doesn't set default value.
>
>       How can i fix it?
>
>
>
> ------------
> With respect,
> Yuri A. Kabaenkov
> hellman@artofit.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


pgsql-general by date:

Previous
From: wsheldah@lexmark.com
Date:
Subject: Re: alter table
Next
From: David Link
Date:
Subject: Integer keys vs. Varchar keys