开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜