Commit 56d982b7 authored by Bruce Momjian's avatar Bruce Momjian

Mention ALTER COLUMN TYPE in FAQ.

parent 5be1e13d
Frequently Asked Questions (FAQ) for PostgreSQL Frequently Asked Questions (FAQ) for PostgreSQL
Last updated: Sun Jan 16 21:40:18 EST 2005 Last updated: Sun Jan 16 22:01:06 EST 2005
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
...@@ -690,7 +690,10 @@ log_* ...@@ -690,7 +690,10 @@ log_*
ALTER TABLE new_table RENAME TO old_table; ALTER TABLE new_table RENAME TO old_table;
COMMIT; COMMIT;
To change the data type of a column, do this: Changing the data type of a column can be done easily in 8.0 and later
with ALTER TABLE ALTER COLUMN TYPE.
In earlier releases, do this:
BEGIN; BEGIN;
ALTER TABLE tab ADD COLUMN new_col new_data_type; ALTER TABLE tab ADD COLUMN new_col new_data_type;
UPDATE tab SET new_col = CAST(old_col AS new_data_type); UPDATE tab SET new_col = CAST(old_col AS new_data_type);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
alink="#0000ff"> alink="#0000ff">
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1> <H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
<P>Last updated: Sun Jan 16 21:40:18 EST 2005</P> <P>Last updated: Sun Jan 16 22:01:06 EST 2005</P>
<P>Current maintainer: Bruce Momjian (<A href= <P>Current maintainer: Bruce Momjian (<A href=
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR> "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
...@@ -854,8 +854,8 @@ ...@@ -854,8 +854,8 @@
<H4><A name="4.4">4.4</A>) How do you remove a column from a <H4><A name="4.4">4.4</A>) How do you remove a column from a
table, or change its data type?</H4> table, or change its data type?</H4>
<P><SMALL>DROP COLUMN</SMALL> functionality was added in release 7.3 with <P><SMALL>DROP COLUMN</SMALL> functionality was added in release 7.3
<SMALL>ALTER TABLE DROP COLUMN</SMALL>. In earlier versions, with <SMALL>ALTER TABLE DROP COLUMN</SMALL>. In earlier versions,
you can do this:</P> you can do this:</P>
<PRE> <PRE>
BEGIN; BEGIN;
...@@ -868,7 +868,10 @@ ...@@ -868,7 +868,10 @@
COMMIT; COMMIT;
</PRE> </PRE>
<P>To change the data type of a column, do this:</P> <P>Changing the data type of a column can be done easily in 8.0
and later with <SMALL>ALTER TABLE ALTER COLUMN TYPE</SMALL>.
<P>In earlier releases, do this:</P>
<PRE> <PRE>
BEGIN; BEGIN;
ALTER TABLE tab ADD COLUMN new_col <i>new_data_type</i>; ALTER TABLE tab ADD COLUMN new_col <i>new_data_type</i>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment