{"title": "Hive\u7b14\u8bb0", "update_time": "2014-10-10 13:18:27", "tags": "\u7b14\u8bb0 hive", "pid": "230", "icon": "hadoop.png"}
hive样例测试 ``` CREATE TABLE words ( word string); LOAD DATA LOCAL INPATH \'/usr/share/dict/words\' OVERWRITE INTO TABLE words; SELECT * FROM words WHERE word LIKE \'%hello%\'; DROP TABLE words ; ``` 对hive表进行重命名 ``` ALTER TABLE table_name RENAME TO new_table_name; ``` 查看表的分区 ``` SHOW PARTITIONS table_name; ``` 查看Hive内置的函数 ``` show functions; ``` 查看Hive函数的具体使用方法 ``` desc function extended 函数名 ;比如desc function extended trim; ``` 设置mapreduce的内存大小 ``` set mapred.child.java.opts=-Xmx2048m; ``` 设置输出结果不压缩 ``` set hive.exec.compress.output=false; ``` hive使用derby db作为metestore的时候,指定数据库位置。在hive-site.xml里添加如下内容: ```
javax.jdo.option.ConnectionURL
jdbc:derby:;databaseName=/home/leileisyh/metastore_db;create=true
``` 对于出现这种hive日志`This is normal. Try local mode failed. Backup to distributed mode.` 请在hive-site.xml里加入下面配置,强制使用分布式模式 ```
hive.exec.mode.local.auto
false
Let hive determine whether to run in local mode automatically
``` 查看表结构(可以查到hive表的具体HDFS路径) ``` desc formatted 表名 ```