Search Postgresql Archives

Re: Creating a column interger with default to not null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24 September 2010 16:05, Chris Barnes
<compuguruchrisbarnes@xxxxxxxxxxx> wrote:
>
> I am confused with what this is telling me.
> I have a table and I am trying to add a new column with constraint not null.
>
>
> What am I missing?
> Chris
>
>
> pgdb001=> alter table schema.table add COLUMN column_name integer not null;
> ERROR:  column "column_name" contains null values

What it's telling you is that the column can't contain null values,
but you're adding a new column with no default, so it will naturally
use null.

Try adding a default like:

ALTER TABLE schema.table ADD COLUMN column_name integer NOT NULL DEFAULT 0;

-- 
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux