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
Comments