0

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.

Stephane
  • 79
  • 1
  • 7
  • 1
    You 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
  • 1
    http://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 Answers1

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).

Community
  • 1
  • 1
ArtemGr
  • 11,684
  • 3
  • 52
  • 85