[Hive] ---- Basic syntax and explanation of Hive table building


Basic syntax of Hive table creation

CREATE [EXTERNAL] TABLE [IF NOT EXIST] table_name
[(col_name data_type [COMMENT COL_COMMENT],.....)]
[COMMENT table_comment]
[PARTITIONED BY (col_name data_type [COMMENT col_comment],....)]
[CLUSTERED BY (col_name,col_name,....)]
[SORTED BY (col_name [ASC|DESC],...)] INFO num_buckets BUCKETS]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION hdfs_path]

Explanation

  • CREATE TABLE Create a table with a specified name. If the name is the same and throw an exception, the user can use IF NOT EXIST to ignore the exception

  • EXTERNALThe keyword can create an external table, and specify a path to the actual data ( LOCATION) when creating the table ; when Hive deletes the table, the metadata and data of the internal table will be deleted together, while the external table only deletes the metadata, not delete data

  • COMMENT Add notes to tables and columns

  • PARTITIONED BY Partition Table

  • CLUSTERED BY Build buckets

  • SORTED BY Sorting (not commonly used)

  • ROW FORMAT Define the format of the line

  • STORED AS Specify storage file type

  • LOCATION Specify the table inHDFSStorage location on

  • LIKE Allows to copy the existing table structure but does not copy the data


Guess you like

Origin blog.csdn.net/qq_45797116/article/details/115068868