1010 alink ="#0000ff ">
1111 < H1 > Frequently Asked Questions (FAQ) for PostgreSQL</ H1 >
1212
13- < P > Last updated: Tue Apr 22 14:02:41 EDT 2003</ P >
13+ < P > Last updated: Mon May 26 15:25:04 EDT 2003</ P >
1414
1515 < P > Current maintainer: Bruce Momjian (< A href =
1616 "mailto:pgman@candle.pha.pa.us "> pgman@candle.pha.pa.us</ A > )< BR >
@@ -87,7 +87,7 @@ <H2 align="center">Operational Questions</H2>
8787 < A href ="#4.3 "> 4.3</ A > ) How do I get a list of tables or other
8888 things I can see in < I > psql</ I > ?< BR >
8989 < A href ="#4.4 "> 4.4</ A > ) How do you remove a column from a
90- table?< BR >
90+ table, or change it's data type ?< BR >
9191 < A href ="#4.5 "> 4.5</ A > ) What is the maximum size for a row, a
9292 table, and a database?< BR >
9393 < A href ="#4.6 "> 4.6</ A > ) How much database disk space is required
@@ -822,9 +822,9 @@ <H4><A name="4.3">4.3</A>) How do I get a list of tables or other
822822 execute the commands you give.</ P >
823823
824824 < H4 > < A name ="4.4 "> 4.4</ A > ) How do you remove a column from a
825- table?</ H4 >
825+ table, or change its data type ?</ H4 >
826826
827- < P > This functionality was added in release 7.3 with
827+ < P > < SMALL > DROP COLUMN </ SMALL > functionality was added in release 7.3 with
828828 < SMALL > ALTER TABLE DROP COLUMN</ SMALL > . In earlier versions,
829829 you can do this:</ P >
830830< PRE >
@@ -838,6 +838,17 @@ <H4><A name="4.4">4.4</A>) How do you remove a column from a
838838 COMMIT;
839839</ PRE >
840840
841+ < P > To change the data type of a column, do this:</ P >
842+ < PRE >
843+ BEGIN;
844+ ALTER TABLE tab ADD COLUMN new_col < i > new_data_type</ i > ;
845+ UPDATE tab SET new_col = CAST(old_col AS < i > new_data_type</ i > );
846+ ALTER TABLE DROP COLUMN old_col;
847+ COMMIT;
848+ </ PRE >
849+ < P > You might then want to do < I > VACUUM FULL tab</ I > to reclaim the
850+ disk space used by the expired rows.</ P >
851+
841852 < H4 > < A name ="4.5 "> 4.5</ A > ) What is the maximum size for a row, a
842853 table, and a database?</ H4 >
843854
0 commit comments