From 90903069e97ab686a5dea96bcd2fb11e73bcdc91 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 26 May 2003 19:25:20 +0000 Subject: Add item for changing a column's data type. --- doc/src/FAQ/FAQ.html | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'doc/src/FAQ') diff --git a/doc/src/FAQ/FAQ.html b/doc/src/FAQ/FAQ.html index 33ba50b2597..c63696aa587 100644 --- a/doc/src/FAQ/FAQ.html +++ b/doc/src/FAQ/FAQ.html @@ -10,7 +10,7 @@ alink="#0000ff">

Frequently Asked Questions (FAQ) for PostgreSQL

-

Last updated: Tue Apr 22 14:02:41 EDT 2003

+

Last updated: Mon May 26 15:25:04 EDT 2003

Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
@@ -87,7 +87,7 @@ 4.3) How do I get a list of tables or other things I can see in psql?
4.4) How do you remove a column from a - table?
+ table, or change it's data type?
4.5) What is the maximum size for a row, a table, and a database?
4.6) How much database disk space is required @@ -822,9 +822,9 @@ execute the commands you give.

4.4) How do you remove a column from a - table?

+ table, or change its data type? -

This functionality was added in release 7.3 with +

DROP COLUMN functionality was added in release 7.3 with ALTER TABLE DROP COLUMN. In earlier versions, you can do this:

@@ -838,6 +838,17 @@
     COMMIT;
 
+

To change the data type of a column, do this:

+
+    BEGIN;
+    ALTER TABLE tab ADD COLUMN new_col new_data_type;
+    UPDATE tab SET new_col = CAST(old_col AS new_data_type);
+    ALTER TABLE DROP COLUMN old_col;
+    COMMIT;
+
+

You might then want to do VACUUM FULL tab to reclaim the + disk space used by the expired rows.

+

4.5) What is the maximum size for a row, a table, and a database?

-- cgit v1.2.3