[英]postgresql: alter multiple columns
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.
我想在单个语句中更改所有这些列(在不同表中),而不是逐列更改类型,以避免遗漏。
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 ).为了让数据库以原子方式更改所有表,您应该将所有更改查询包含在事务中(PostgreSQL支持事务性 DDL )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.