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 > Adding columns ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 1967 of 2083
Post > Topic >>

Adding columns NOT NULL

by laurent_roche@[EMAIL PROTECTED] (Laurent ROCHE) Mar 7, 2008 at 02:30 AM

--0-973054228-1204885829=:99305
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,=0A=0AThere is a little anomaly in the way adding an extra column is
tre=
ated in pgAdmin III 1.8.2.=0A... particularly if this is a NOT NULL
column.=
=0A=0AWhen adding the column my_col with a DEFAULT value, the code
generate=
d will be:=0AALTER TABLE my_table ADD COLUMN my_col boolean;=0AALTER TABLE
=
my_table ALTER COLUMN my_col SET DEFAULT false;=0A=0AThis works fine ...
as=
 long as I don't insert columns with NOT NULL property.=0AIn which case, I
=
SUPPOSE it generates:=0AALTER TABLE my_table ADD COLUMN my_col boolean NOT
=
NULL;=0AALTER TABLE my_table ALTER COLUMN my_col SET DEFAULT
false;=0A=0ATh=
is will not work, because the column is created with no default (hence no
v=
alues) and does not sup****t NULL values, hence creation fails.=0A=0A** In
p=
gAdmin, adding an extra column with NOT NULL property is impossible !
**=0A=
=0ASo I would suggest to generate the code:=0AALTER TABLE my_table ADD
COLU=
MN my_col boolean NOT NULL DEFAULT false;=0A=0AWhich does work !=0AAnd
that=
 allows to create a column with not NULL values, in one operation, and
more=
 im****tantly with the column populated.=0AAt the moment, to perform the
sam=
e operation I have to=0A - create the column, with NULL values.=0A -
update=
 the table to populate the column=0A - modify the column to NOT NULL=0A...
=
or write my-self the ALTER TABLE statement !=0A=0A=0ACheers,=0AL@[EMAIL PROTECTED]
 Froggy=0A=0A=0A=0A=0A     
________________________________________=
_____________________________________ =0AEnvoyez avec Yahoo! Mail. Une
boit=
e mail plus intelligente http://mail.yahoo.fr
--0-973054228-1204885829=:99305
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><style type=3D"text/css"><!-- DIV {margin:0px;}
--></style></he=
ad><body><div
style=3D"font-family:courier,monaco,monospace,sans-serif;font=
-size:10pt">Hi,<br><br>There is a little anomaly in the way adding an
extra=
 column is treated in pgAdmin III 1.8.2.<br>... particularly if this is a
N=
OT NULL column.<br><br>When adding the column my_col with a DEFAULT value,
=
the code generated will be:<br>ALTER TABLE my_table ADD COLUMN my_col
boole=
an;<br>ALTER TABLE my_table ALTER COLUMN my_col SET DEFAULT
false;<br><br>T=
his works fine ... as long as I don't insert columns with NOT NULL
property=
..<br>In which case, I SUPPOSE it generates:<br>ALTER TABLE my_table ADD
COL=
UMN my_col boolean NOT NULL;<br>=0AALTER TABLE my_table ALTER COLUMN
my_col=
 SET DEFAULT false;<br><br>This will not work, because the column is
create=
d with no default (hence no values) and does not sup****t NULL values,
hence=
 creation fails.<br><br>** In pgAdmin, adding an extra column with NOT
NULL=
 property is impossible ! **<br><br>So I would suggest to generate the
code=
:<br>ALTER TABLE my_table ADD COLUMN my_col boolean NOT NULL DEFAULT
false;=
<br><br>Which does work !<br>And that allows to create a column with not
NU=
LL values, in one operation, and more im****tantly with the column
populated=
..<br>At the moment, to perform the same operation I have to<br>&nbsp;-
crea=
te the column, with NULL values.<br>&nbsp;- update the table to populate
th=
e column<br>&nbsp;- modify the column to NOT NULL<br>... or write my-self
t=
he ALTER TABLE statement !<br>=0A<br>=0A<br>Cheers,<br>L@[EMAIL PROTECTED]
>The
Computing=
 Froggy<div><br></div></div><br>=0A=0A=0A=0A      <hr size=3D"1">
=0AEnvoy=
=C3=A9 avec <a
href=3D"http://us.rd.yahoo.com/mailuk/taglines/isp/control/*=
http://us.rd.yahoo.com/evt=3D52423/*http://fr.docs.yahoo.com/mail/overview/=
index.html">Yahoo! Mail</a>.<br>Une boite mail plus intelligente.
</a></bod=
y></html>
--0-973054228-1204885829=:99305--
 




 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
tan13V112 Thu Jul 24 12:55:03 CDT 2008.