【问题标题】:How to add multiple columns to a table in Postgres?如何在 Postgres 中的表中添加多个列?
【发布时间】:2011-07-12 18:06:03
【问题描述】:

如何使用 pgadmin3 在 PostgreSQL 的一个查询语句中添加多个列?

【问题讨论】:

    标签: postgresql pgadmin


    【解决方案1】:

    试试这个:

    ALTER TABLE table ADD COLUMN col1 int, ADD COLUMN col2 int;
    

    【讨论】:

    【解决方案2】:
    ALTER TABLE  IF EXISTS  TABLEname 
    add ADD  COLUMN   IF NOT EXISTS  column_name data_type  [column_constraint];
    

    column_constraints 是可选的详细查询

    【讨论】:

    • 哎哟...上述两种语法都不适用于 Redshift :-( 我收到错误:错误:在“,”或附近出现语法错误:第 1 行:ALTER TABLE x ADD COLUMN col1 int, ADD COLUMN colX int
    猜你喜欢
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-15
    • 2017-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多