My database has severals table with some column type 'money'. I would like to alter all these columns (in different tables) in a single statement rather than change type column by column, to avoid omissions.
Asked
Active
Viewed 1,816 times
0
-
1You need one statement per table. There is no way to alter columns from multiple tables in a single statement. It can be done in a single transaction though. – Apr 15 '14 at 08:20
-
Ok, how can I do this. (one statement per table) – Stephane Apr 15 '14 at 08:34
-
1http://www.postgresql.org/docs/current/static/sql-altertable.html – Apr 15 '14 at 08:36
-
I manage to alter one column in the table, but don't to alter multiple column in the sam table – Stephane Apr 15 '14 at 09:41
1 Answers
0
You'll have to repeat the altering query for every column.
You might want to create a program code to do that for you. You know, with loops.
In order for the database to alter all the tables atomically you should enclose all the altering queries in a transaction (PostgreSQL supports transactional DDL).