Create Table is a statement used to create a table in Hive. The syntax and example are as follows:
Syntax
CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.] table_name [(col_name data_type [COMMENT col_comment], ...)] [COMMENT table_comment] [ROW FORMAT row_format] [STORED AS file_format]
Example
year name state
2012 manish del
2013 nitin jammu
2014 nidhi jaipur
2015 kamal bangalore
2016 jatin mumbai
2017 bajaj rohtak
2018 indira gurgaon
2019 kamal jaipur
2020 manish del
2021 nitin jammu
2022 nidhi jaipur
2023 kamal bangalore
2024 jatin mumbai
2025 bajaj rohtak
2026 indira gurgaon
2027 kamal jaipur
2028 manish del
2029 nitin jammu
2030 nidhi jaipur
2031 kamal bangalore
hive>create table City006(year Int,name String,city String) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' STORED AS TEXTFILE;
If you add the option IF NOT EXISTS, Hive ignores the statement in case the table already exists.
On successful creation of table, you get to see the following response:
OK Time taken: 5.905 seconds hive> |
04:40
Tags :
Hive Tutorials
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments