Slide 19
Slide 19 text
CREATE TABLE creates a table with the given name. An error is thrown if a table or view
with the same name already exists. You can use IF NOT EXISTS to skip the error. The
syntax for creating a table is as below
CREATE TABLE table_name
[COMMENT table_comment]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION hdfs_path]
Ex: CREATE TABLE hivedemo.employees (EMPLOYEE_ID int,FIRST_NAME String,
LAST_NAME String, EMAIL String, PHONE_NUMBER String, HIRE_DATE String,
JOB_ID String, SALARY String, COMMISSION_PCT int, MANAGER_ID String,
DEPARTMENT_ID String)
COMMENT 'This is the Employees table'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n’
STORED AS TEXTFILE
LOCATION '/user/hive/warehouse/hivedemo/employees‘;
HIVE DDL–Create Tables