Insert data into an ACID table

You can insert data into an Optimized Row Columnar (ORC) table that resides in the Hive warehouse.

You can specify partitioning as shown in the following syntax:

INSERT INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)] VALUES values_row [, values_row...]

where

values_row is (value [, value]) .

A value can be NULL or any SQL literal.

  1. Create a table to contain student information.
    CREATE TABLE students (name VARCHAR(64), age INT, gpa DECIMAL(3,2));
  2. Insert name, age, and gpa values for a few students into the table.
    INSERT INTO TABLE students VALUES ('fred flintstone', 35, 1.28), ('barney rubble', 32, 2.32);
  3. Create a table called pageviews and assign null values to columns you do not want to assign a value.
    CREATE TABLE pageviews (userid VARCHAR(64), link STRING, from STRING) PARTITIONED BY (datestamp STRING) CLUSTERED BY (userid) INTO 256 BUCKETS;
    INSERT INTO TABLE pageviews PARTITION (datestamp = '2014-09-23') VALUES ('jsmith', 'mail.com', 'sports.com'), ('jdoe', 'mail.com', null); 
    INSERT INTO TABLE pageviews PARTITION (datestamp) VALUES ('tjohnson', 'sports.com', 'finance.com', '2014-09-23'), ('tlee', 'finance.com', null, '2014-09-21');