Skip to main content

How do you load the data from one schema to other schema?

  • February 15, 2013
  • 1 reply
  • 8 views

Forum|alt.badge.img+2
How do you load the data from one schema to other schema ( table to table in same database). What all options we have to do this in vertica?

1 reply

Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 15, 2013
There is not a direct command that will copy one schema tables to another schema. However, the script below will help you to automate the process. Make sure that the schema is created and the tables do not exist in the new schema. 1- Create a new schema create schema NEW_SCHEMA ; 2- Create a file for example: copy_schema.sh 3- Copy the content below in the file created above. #!/bin/bash user=dbadmin new_schema=test old_schema=public vsql -ta -c " SELECT 'Create table $new_schema.' || table_name || ' as select * from ' || table_schema || '.' || table_name || '; ' FROM tables where table_schema like '$old_schema'; " | vsql 4- Save the file and give execution privileges chmod +x copy_schema.sh 5- From the operating system command line, as dbadmin user. Run the script ./copy_schema.sh