User Tools

Site Tools

A PCRE internal error occured. This might be caused by a faulty plugin


**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]


====== INSERT DIRECTORY Statement ====== INSERT DIRECTORY statement allows you to write the query results to a local or HDFS-compatible file system. **Syntax**: <code language=sql> INSERT OVERWRITE [LOCAL] DIRECTORY directory select_statement </code> Notes: * //directory// specifies the target directory (path, variable or expression) * //select_statement// specifies the query (you can also use dynamic SQL string) **Examples:** Export sales data: <code language=sql> insert overwrite directory '/data/sales_daily' select * from sales_daily; </code> Export sales data from the specified table and put to the directory for the current date: <code language=sql> declare tabname string = 'sales_daily'; insert overwrite directory '/data/sales_' || current_date 'select * from ' || tabname; </code> **Compatibility:** Hive **Version**: HPL/SQL 0.3.17 See also: * [[copy|COPY]] * [[copy-from-local|COPY FROM LOCAL]]