Two ways to load data in Hive table

The first is insert

insert overwrite table mytable partition (dt='20150617') select ....

The above statement is the insert statement of hive.
The same point as the SQL of the database is that insert is to insert data into the table, overwrite is to overwrite, and into is to append. The
difference is that the insert statement of hive must have the keyword table, and if it is a partitioned table. Specify the partition after the table name

The insert statement is used for data interaction between hive tables and tables

The second is load

LOAD DATA LOCAL INPATH '/path' OVERWRITE  INTO TABLE mytable PARTITION (dt='20200901')

The characteristic of the load statement is that it is easy to use, but the data style is not as flexible as the insert statement

The load statement is used to load files on local or hdfs, where LOCAl means local, if you want to load data on hdfs, just remove LOCAL

OVERWRITE also means overwriting, if you just want to add and write to remove it

The load statement when you load the folder, if there is a file with the same name below, it will be named from

Remember

No matter which way to load the data, if it is not a partition table, then do not have a partition keyword

Guess you like

Origin blog.csdn.net/dudadudadd/article/details/113129061