Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • INSERT OVERWRITE statements to directories, local directories, and tables (or partitions) can all be used together within the same query.
  • INSERT OVERWRITE statements to HDFS filesystem directories are the best way to extract large amounts of data from Hive. Hive can write to HDFS directories in parallel from within a map-reduce job.
  • The directory is, as you would expect, OVERWRITten; in other words, if the specified path exists, it is clobbered and replaced with the output.
  • As of Hive 0.11.0 the separator used can be specified, in earlier versions it was always the ^A character (\001)

Inserting into tables from SQL

The INSERT...VALUES statement can be used to insert data into tables directly from SQL.

Note

INSERT...VALUES is available starting in Hive 0.14

Code Block
Standard Syntax:
INSERT INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)] VALUES values_row [, values_row...]
 
Where values_row is:
( value [, value] )
Where a value is either null or any valid SQL literal
Synopsis
  • Each row listed in the VALUES clause is inserted into table tablename.
  • Values must be provided for every column in the table.  The standard SQL syntax that allows the user to insert values into only some columns is not yet supported.  To mimic the standard SQL nulls can be provided for columns the user does not wish to assign a value to.
  • If the table being inserted into supports ACID and a transaction manager that supports ACID is in use, this operation will be auto-committed upon successful completion.