使用hive 0.14建议使用示例创建,更新和删除示例配置单元件查询

时间:2014-12-25 19:25:47

标签: java hadoop hive

请任何人帮我用hive 0.14创建hive事务表。另外,举例说明如何在创建的配置单表

的记录中执行更新和删除操作

1 个答案:

答案 0 :(得分:1)

Need to add additional settings in hive-site.xml and 

使用ACID输出格式支持创建表。

New Configuration Parameters for Transactions
 hive.support.concurrency – true
 hive.enforce.bucketing – true
 hive.exec.dynamic.partition.mode – nonstrict
 hive.txn.manager –org.apache.hadoop.hive.ql.lockmgr.DbTxnManager
 hive.compactor.initiator.on – true
 hive.compactor.worker.threads – 1


You can also set the parameters by running above lines on hive terminal for temp.,
then run below queries to perform create, insert, update, delete, select operations on table.

**1.Create HiveTest table with ACID support**

create table HiveTest 
   (EmployeeID Int,FirstName String,Designation String,
     Salary Int,Department String) 
   clustered by (department) into 3 buckets 
   stored as orc TBLPROPERTIES ('transactional'='true');

**2. INSERT**

insert into table HiveTest 
     values(1,'Rohit','MD',88000,'Development');

insert into table HiveTest 
     values(2,'anil','CEO',99999,'IT');

**3. SELECT**

SELECT * FROM hivetest;

**4.UPDATE**

 update HiveTest 
    set salary = 111111 
    where employeeid = 2;

**5. DELETE**

 delete from HiveTest
     where employeeid=1;

**6. SELECT**`enter code here`

SELECT * FROM hivetest;

'Insert into ..' statement cannot be used for complex datatypes.
 Hive does not support literals for complex types, so it is not possible to use them in INSERT...VALUES clauses.

Thanks