Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Pgadmin Support > Re: Adding colu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 1967 of 2158
Post > Topic >>

Re: Adding columns NOT NULL

by tino@[EMAIL PROTECTED] (Tino Wildenhain) Mar 7, 2008 at 03:08 PM

Hi,

Laurent ROCHE wrote:
> Hi,
> 
> There is a little anomaly in the way adding an extra column is treated 
> in pgAdmin III 1.8.2.
> ... particularly if this is a NOT NULL column.
> 
> When adding the column my_col with a DEFAULT value, the code generated 
> will be:
> ALTER TABLE my_table ADD COLUMN my_col boolean;
> ALTER TABLE my_table ALTER COLUMN my_col SET DEFAULT false;
> 
> This works fine ... as long as I don't insert columns with NOT NULL 
> property.
> In which case, I SUPPOSE it generates:
> ALTER TABLE my_table ADD COLUMN my_col boolean NOT NULL;
> ALTER TABLE my_table ALTER COLUMN my_col SET DEFAULT false;
> 
> This will not work, because the column is created with no default (hence

> no values) and does not sup****t NULL values, hence creation fails.
> 
> ** In pgAdmin, adding an extra column with NOT NULL property is 
> impossible ! **
> 
> So I would suggest to generate the code:
> ALTER TABLE my_table ADD COLUMN my_col boolean NOT NULL DEFAULT false;
> 
> Which does work !
> And that allows to create a column with not NULL values, in one 
> operation, and more im****tantly with the column populated.

Yes but it would be too special to just only have "false if boolean".
In this case either the "NOT NULL" option has to go or the
default value should be possible to specify. (otoh, it should
be a rare case anyway that you have a single default value
for all rows)

Regards
Tino

-- 
Sent via pgadmin-sup****t mailing list (pgadmin-sup****t@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-sup****t
 




 3 Posts in Topic:
Adding columns NOT NULL
laurent_roche@[EMAIL PROT  2008-03-07 02:30:29 
Re: Adding columns NOT NULL
tino@[EMAIL PROTECTED] (  2008-03-07 15:08:23 
Re: Adding columns NOT NULL
dpage@[EMAIL PROTECTED]   2008-03-11 09:09:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 17:16:12 CST 2008.