【问题标题】:Rename two columns in netezza using single query使用单个查询重命名 netezza 中的两列
【发布时间】:2015-02-05 05:06:19
【问题描述】:

我是 netezza 的新手。我需要知道如何用一个查询重命名两列。

我试过了,

ALTER TABLE tabemp RENAME COLUMN salary to empsalary and name to empname;

ALTER TABLE tabemp RENAME COLUMN salary to empsalary , name to empname;

但这些都不起作用。

谢谢。

【问题讨论】:

    标签: multiple-columns rename netezza alter


    【解决方案1】:

    对于查询,一次只能重命名一列。您可以编写包装脚本来重命名多个列,或者使用 IBM Netezza Performance 门户来编辑表。检查链接here

    【讨论】:

      【解决方案2】:

      使用 ALTER TABLE 一次只能重命名一列。

      From the documentation, which can be found at this link, 你可以看到 ADD COLUMN 是唯一允许多个规范的操作:

      ALTER TABLE <table> <action> [ORGANIZE ON {(<columns>) | NONE}]
      
      Where <action> can be one of:
      
      ADD COLUMN <col> <type> [<col_constraint>][,…] |  
      
      ADD <table_constraint> |  
      
      ALTER [COLUMN] <col> { SET DEFAULT <value> |  DROP DEFAULT } |  
      
      DROP [COLUMN] column_name[,column_name…] {CASCADE | RESTRICT } |  
      
      DROP CONSTRAINT <constraint_name> {CASCADE | RESTRICT} | 
      
      MODIFY COLUMN (<col> VARCHAR(<maxsize>)) |  
      
      OWNER TO <user_name> | 
      
      RENAME [COLUMN] <col> TO <new_col_name> | 
      
      RENAME TO <new_table> |  
      
      SET PRIVILEGES TO <table>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-17
        相关资源
        最近更新 更多