hive_execute()

Description:

Execute Hive’s SQL-like queries.

Syntax:

hive_execute(con,sql)

Note:

This external library function (See External Library Guide) supports executing Hive’s SQL-like statements, including create table, drop table, insert into, insert overwrite, and create view.

Parameter:

con

Database connection string

sql

A SQL query statement

Return value:

Boolean value

Example:

 

A

 

1

=hive_client("hdfs://192.168.0.8:9000/","thrift://192.168.0.8:9083","hive","asus")

Connect to the hive database.

2

=hive_execute(A1, "create table stu2( id string, name string,age string)")

Create a table

3

=hive_execute(A1, "drop table stu")

Drop a table.

4

=hive_execute(A1, "alter table stu2 add columns (ncol string)")

Add a column to the table.

5

=hive_execute(A1, "insert into stu2 values ('2','dfff','21','lll')")

Insert data into the table.

6

=hive_execute(A1,"insert overwrite table stu select * from stu2

Overwrite table stu with data in table stu2 .

Related function:

hive_open()