HPL/SQL is included to Apache Hive since version 2.0
HPL/SQL is included to Apache Hive since version 2.0
COPY statement allows to transfer data between tables and files. Use it to transfer relatively small volumes of data i.e. query results, look-up and dimension tables.
When you copy data between tables they can be located in different databases.
Syntax:
Export data to a file:
COPY table_name | (select_stmt) TO [HDFS] file_name [options] options: DELIMITER 'char' | SQLINSERT target_table_name
Copy data between existing tables:
COPY table_name | (select_stmt) TO target_table_name AT target_conn_name [options] options: BATCHSIZE num
Notes:
Example 1:
Export the query results to a file:
COPY (SELECT id, name FROM sales.users WHERE local_dt = CURRENT_DATE) TO /data/users.txt DELIMITER '\t';
Example 2:
Generate SQL INSERT statements:
COPY sales.users TO /data/users2.sql SQLINSERT sales.users;
Example 3:
Copy rows from between tables in different databases:
COPY sales.users TO sales.users2 AT tdconn;
Compatibility: HPL/SQL Extension, PostgreSQL
Version: HPL/SQL 0.3.7
See also: