none
Change table name or schema on existing table

    Question

  • Hi,

    Is there an option to change the table name or change its schema, after creation.

    My scenario is i have table with data and table is now unused, but i need to keep it for manual data reading. so was looking for option is i can rename the table like archived_table or move it to a new schema like archived.table.

    Thanks


    singhhome

    Thursday, November 30, 2017 7:04 PM

Answers

  • Hi Singhhome,

    Such option is currently not available. If you feel that it should be added, please upvote this ask on Uservoice...

    For the time being, you can achieve this by running a CTAS statement to create a copy of existing table with a new name and/or schema, e.g.

    CREATE TABLE newSchema.myTableCopy (
           INDEX clx_Id CLUSTERED(Id ASC) 
           DISTRIBUTED BY HASH (Id)
    ) AS SELECT * FROM oldSchema.myTable;

    Maja


    Wednesday, December 6, 2017 8:48 AM