开发者

How to add same column to multiple tables in a DB and fill it with a constant value?

开发者 https://www.devze.com 2023-03-24 17:04 出处:网络
I have a database with multiple tables. I want to add a new column to each one of them and fill these column 开发者_JAVA百科with some constant integer value. My search on google did not give me desire

I have a database with multiple tables. I want to add a new column to each one of them and fill these column 开发者_JAVA百科with some constant integer value. My search on google did not give me desired answer.

I am using PostgreSQL and PHP.


Can't you use ALTER TABLE to create a new column and SET DEFAULT to set the default value to all column fields?

Like:

ALTER TABLE mytable ADD COLUMN mynumber integer; ALTER mynumber SET DEFAULT 7

(http://www.postgresql.org/docs/8.2/static/sql-altertable.html)

0

精彩评论

暂无评论...
验证码 换一张
取 消