在Hive中,分區(qū)表可以通過(guò)INSERT語(yǔ)句插入數(shù)據(jù),語(yǔ)法如下:
INSERT INTO TABLE table_name [PARTITION (partition_col1=val1, partition_col2=val2, ...)]
VALUES (value1, value2, ...);
例如,假設(shè)有一個(gè)名為employee
的分區(qū)表,有兩個(gè)分區(qū)列year
和department
,可以按照以下方式插入數(shù)據(jù):
INSERT INTO TABLE employee PARTITION (year=2021, department='IT')
VALUES ('John', 'Smith', 100000);
INSERT INTO TABLE employee PARTITION (year=2020, department='HR')
VALUES ('Alice', 'Johnson', 80000);
這樣就可以向分區(qū)表employee
中插入數(shù)據(jù),并指定數(shù)據(jù)所屬的分區(qū)。