大資料之Hive:DML資料操作(四)
阿新 • • 發佈:2021-02-07
技術標籤:大資料系列二
1.查詢(查)
1-1.全表查詢
hive (default)> select * from emp;
1-2.選擇特定列查詢
hive (default)> select empno, ename from emp;
2.刪除和更改
刪除
delete from stu where id=1;
修改
update stu set name=zhangsan where id = 1;
特別注意:
如果一個表要實現update和delete功能,該表就必須支援ACID,而支援ACID,就必須滿足以下條件:
1、表的儲存格式必須是ORC(STORED AS ORC);
3、Table property中引數transactional必須設定為True(tblproperties(‘transactional’=‘true’));
4、以下配置項必須被設定:
Client端:
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
hive.txn.manager – org.apache.hadoop.hive.ql.lockmgr.DbTxnManager(經過測試,服務端也需要設定該配置項)
3.列別名
緊跟列名,也可以在列名和別名之間加入關鍵字‘AS’
hive (default)> select ename AS name, deptno dn from emp;
4.算術運算子
hive (default)> select sal +1 from emp;