Introduction to Hive table creation and table structure modification

Source: Internet
Author: User

Hive is a data Warehouse tool based on Hadoop that maps structured data in a distributed file system HDFs to a single table. The mapped metadata is saved in a user-defined database and can be used in the language of the class sql: Hive QL for data analysis.


And hive can be based on the parameters of the table, the table in the HDFs of the actual data in a specific format to save. Therefore, Hive has good performance in large data reading.

The following describes how hive can modify the structure of a table after creating a table and creating a table using Hive QL.


This article will focus on the meaning of each structure in the Hive table. The aim is to be able to define the structure of the hive more flexibly after we understand the structure of hive, so as to further realize the customization of hive structures.


In the Languagemanual DDL in Hive's official website, the Hive table creation syntax is:

CREATE [temporary] [EXTERNAL] TABLE [IF not EXISTS] [db_name.] TABLE_NAME    [(col_name data_type [COMMENT col_comment], ...)]    [COMMENT table_comment]  & nbsp [Partitioned by (Col_name data_type [COMMENT col_comment], ...)]    [CLUSTERED by (Col_name, col_name, ...) [SORTED by (Col_name [asc| DESC], ...) into num_buckets buckets]    [skewed by (Col_name, col_name, ...) On ([(Col_value, Col_value, ...), ... | Col_value, Col_value, ...] [STORED as directories] (Note:only available starting with hive  0.10.0)]    [    [ROW FORMAT Row_format] [STORED as File_format]     | STORED by  ' storage.handler.class.name '   [with serdeproperties (...)]   (Note:only available starting with hive  0.6.0)   ]    [LOCATION Hdfs_path]  &nb Sp [Tblproperties (Property_name=property_value, ...)]   (Note:only available starting with hive  0.6.0)  &NBsp [As select_statement]  (Note:only available starting with hive  0.5.0, and not supported when creating Exter NAL tables.) Or: CREATE [temporary] [EXTERNAL] TABLE [IF not EXISTS] [db_name.] table_name    like Existing_table_or_view_name    [LOCATION Hdfs_path]
1, when creating a table, hive will check whether there is a table with the same name, if there is a table with the same name, it will error, and table creation failed. You can do this without creating a table with the same name by adding an if not exists, without an error.
2, temporary keyword, this is the hive 0.14.0 version after the new addition function. As the name suggests, is the meaning of the temporary table. Links: https://issues.apache.org/jira/browse/HIVE-7090 temporary tables are created and are valid only for the current session. The data is saved in the user's temporary directory, and the metadata and actual data of the table are deleted after the session.    References to the table are also deleted. Temporary table restrictions: A, does not support partition B, does not support index C, does not support static columns

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.