We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Renaming a View — Vertica Forum

Renaming a View

You are probably aware that you can rename a table using the ALTER TABLE … RENAME command.

Example:

dbadmin=> \dt test
              List of tables
Schema | Name | Kind  |  Owner  | Comment
--------+------+-------+---------+---------
public | test | table | dbadmin |
(1 row)

dbadmin=> ALTER TABLE test RENAME TO test_new;
ALTER TABLE

But you might not know that you can just as easily rename a database view using a very similar command!

Example:

dbadmin=> \dv test_view;
            List of View Fields
Schema |   View    | Column | Type | Size
--------+-----------+--------+------+------
public | test_view | c1     | int  |    8
(1 row)

dbadmin=> ALTER VIEW test_view RENAME TO test_view_new;
ALTER VIEW

Have fun!

Comments

  • can we rename database?

  • Jim_KnicelyJim_Knicely - Select Field - Administrator

    Not easily! That is, there is not a simple SQL DDL command to rename a database...

    dbadmin=> SELECT database_name FROM databases;
     database_name
    ---------------
     test_db
    (1 row)
    
    dbadmin=> ALTER DATABASE test_db RENAME TO test_db_new;
    ERROR 2676:  Command ALTER DATABASE is not supported
    

    But there is a way to rename a database. You'll need to open a support ticket for that. Most of the time it's just easier to create a new database and re-load it.

Sign In or Register to comment.