Discussion:
adding defaults
(too old to reply)
Jodi Kanter
2004-07-14 16:34:53 UTC
Permalink
Can field specific defaults easily be added to a table that is already
in existence and has data in it? I cannot seem to locate the correct
ALTER command in any of my books.
Thanks
Jodi
--
/_______________________________
//Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
***@virginia.edu <mailto:***@virginia.edu>/



/ /

/ /
Oliver Elphick
2004-07-14 16:52:21 UTC
Permalink
Post by Jodi Kanter
Can field specific defaults easily be added to a table that is already
in existence and has data in it? I cannot seem to locate the correct
ALTER command in any of my books.
ALTER TABLE table ALTER COLUMN column SET DEFAULT expression
--
Oliver Elphick ***@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"God is faithful, by whom ye were called unto the
fellowship of his Son Jesus Christ our Lord."
I Corinthians 1:9


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
Peter Eisentraut
2004-07-14 17:09:24 UTC
Permalink
Post by Jodi Kanter
Can field specific defaults easily be added to a table that is
already in existence and has data in it? I cannot seem to locate the
correct ALTER command in any of my books.
ALTER TABLE a ALTER COLUMN b SET DEFAULT c;
--
Peter Eisentraut
http://developer.postgresql.org/~petere/


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ***@postgresql.org
Rosser Schwarz
2004-07-14 17:11:51 UTC
Permalink
Post by Jodi Kanter
Can field specific defaults easily be added to a table that is already
in existence and has data in it? I cannot seem to locate the correct
ALTER command in any of my books.
$ psql -c "\h alter table" | grep -iC 1 default

ALTER TABLE [ ONLY ] name [ * ]
ALTER [ COLUMN ] column { SET DEFAULT expression | DROP DEFAULT }
...

/rls
--
:wq

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ***@postgresql.org
Loading...