How do I move a table to a different schema?

Moderator: NorbertKrupa

Post Reply
sam
Newbie
Newbie
Posts: 14
Joined: Thu Sep 12, 2013 9:48 pm

How do I move a table to a different schema?

Post by sam » Thu Jan 23, 2014 4:28 pm

Hi guys,

Is there a simple way of moving a table to a different schema? I tried to search the site before posting my question. I couldn't find an answer.

Thank you.

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: How do I move a table to a different schema?

Post by JimKnicely » Thu Jan 23, 2014 4:40 pm

Hi,

You can simply ALTER the table and SET a new schema for it...

Example:

Code: Select all

dbadmin=> SELECT table_schema FROM tables WHERE table_name = 'my_table';
 table_schema
--------------
 schema1
(1 row)

dbadmin=> ALTER TABLE schema1.my_table SET SCHEMA schema2;
ALTER TABLE

dbadmin=> SELECT table_schema FROM tables WHERE table_name = 'my_table';
 table_schema
--------------
 schema2
(1 row)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “New to Vertica Database Administration”