10
10
alink ="#0000ff ">
11
11
< H1 > Frequently Asked Questions (FAQ) for PostgreSQL</ H1 >
12
12
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 >
14
14
15
15
< P > Current maintainer: Bruce Momjian (< A href =
16
16
"mailto:pgman@candle.pha.pa.us "> pgman@candle.pha.pa.us</ A > )< BR >
@@ -87,7 +87,7 @@ <H2 align="center">Operational Questions</H2>
87
87
< A href ="#4.3 "> 4.3</ A > ) How do I get a list of tables or other
88
88
things I can see in < I > psql</ I > ?< BR >
89
89
< 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 >
91
91
< A href ="#4.5 "> 4.5</ A > ) What is the maximum size for a row, a
92
92
table, and a database?< BR >
93
93
< 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
822
822
execute the commands you give.</ P >
823
823
824
824
< 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 >
826
826
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
828
828
< SMALL > ALTER TABLE DROP COLUMN</ SMALL > . In earlier versions,
829
829
you can do this:</ P >
830
830
< PRE >
@@ -838,6 +838,17 @@ <H4><A name="4.4">4.4</A>) How do you remove a column from a
838
838
COMMIT;
839
839
</ PRE >
840
840
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
+
841
852
< H4 > < A name ="4.5 "> 4.5</ A > ) What is the maximum size for a row, a
842
853
table, and a database?</ H4 >
843
854
0 commit comments