Monday, 24 February 2014

Rename Table, Table column or view in vertica




        Below syntax's to rename a Table, column and view.

Rename a Table: 
               ALTER TABLE <Schema Name>.<Table Name> RENAME TO <New Name for that table>

     Example:
               ALTER TABLE Test.Sample1 RENAME TO SAMPLE2


Rename a Column:
                 ALTER TABLE <Schema Name>.<Table Name> RENAME COLUMN <Column Name>  TO  <New Name For that column>

       Example:
                ALTER TABLE Test.Sample RENAME COLUMN Sample_Id TO Sample_2;


Rename a View:
                ALTER VIEW <Schema Name>.<Table Name> RENAME TO <New Name>

        Example:
                 ALTER VIEW TEST.SAMPLE4 RENAME TO SAMPLE6

1 comment:

  1. Hello,
    Any idea how to rename a column only if the table exists ?
    Thanks

    ReplyDelete