April 2015
Intermediate to advanced
504 pages
11h 41m
English
Thankfully, changing column data types is not an everyday task, but when we need to do it, we must know all the details so that we can perform the conversion on a production system without any errors.
Let's start with a simple example of a table, as follows:
postgres=# select * from birthday;
This gives the following output:
name | dob -------+-------- simon | 690926 (1 row)
The preceding table was created using this command:
CREATE TABLE birthday ( name TEXT , dob INTEGER);
Let's say we want to change the dob column to another data type. Let's try with a simple example first, as follows:
postgres=# ALTER TABLE birthday postgres-# ALTER COLUMN dob SET DATA TYPE text; ALTER TABLE