Re: alter table

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "sec" <sec(at)artofit(dot)com>
Cc: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: alter table
Date: 2001-11-30 16:44:12
Message-ID: 001701c179be$4075be90$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)artofit(dot)com>
To: <pgsql-general(at)postgresql(dot)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(at)artofit(dot)com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

  • alter table at 2001-11-30 15:22:56 from Yuri A. Kabaenkov

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Link 2001-11-30 16:55:43 Integer keys vs. Varchar keys
Previous Message wsheldah 2001-11-30 16:30:42 Re: alter table