To import data from a database we can use the copy from command as described here
-make sure that the object already exists(the DDL) on the database, if not get the DDL of it with the function and create on the new database, to do so use the following commands:
After this run the output on to the target database.
Test the " CONNECT " command:
-the connect command enables you to connect to another Vertica database that will subsequently enable export and copy from commands.
Syntax of the CONNECT command is :
Where the options are :
database-the target database name;
user-username used in to connect;
password-the password of the user;
host-hostname or ipaddress of one of the nodes;
port-the port on which the Vertica service is running on;
You cannot open more then one connection to at the same time, and the connection will be available until you use the DISCONECT command.
Test the " DISCONECT " command:
Closes a previously-established connection to another Vertica database.
Syntax of the DISCONECT command is :
Now back to our COPY FROM command, and see how this works.
Syntax for the COPY FROM command:
To be able to run this command you need to have the following permisions:
SELECT privileges on the source table.
USAGE privilege on source table schema.
INSERT privileges for the destination table in target database.
USAGE privilege on destination table schema.
Example showing how to copy several columns from a table in the source database into a table in the local database.