标签:des style blog http io color ar 使用 sp
hive一次使用命令:$ hive -e "select * from mytable limit 1;" OK name1 1 name2 2 Time taken: 3.935 seconds $ hive -e "select * from mytable limit 1;" > /tmp/myfile $ cat /tmp/myfile OK name1 1 name2 2 Time taken: 3.935 seconds
$ hive -S -e "select * from mytable limit 1;" > /tmp/myfile $ cat /tmp/myfile name1 1 name2 2
$ hive -f /tmp/queries.hql
$ cat /tmp/queries.hql select * from mytable limit 1; $ hive hive> source /tmp/queries.hql; ...
hive> ! /bin/echo "hello, world!"; "hello, world";
hive> dfs -ls / ; Found 2 items drwxr-xr-x - root supergroup 0 2014-11-06 12:00 /flag drwxr-xr-x - root supergroup 0 2014-11-07 15:00 /user
-- Copyright 2012 -- This is a test select * from mytable limit 1;
create table employee ( name string, age tinyint, salary float, subordinates array<string>, address struct<country:string,province:string,city:string,street:string> );
create table employee ( name string, age tinyint, salary float, subordinates array<string>, address struct<country:string,province:string,city:string,street:string> ) row format delimited fields terminated by '\001' collection items terminated by '\002' map keys terminated by '\003' lines terminated by '\n' stored as textfile;其中,row format delimited这组关键字必须要写在其他字句(除了stored as ...)之前。
hive> create database financial;
hive> create database financial if not exists financial;
hive> show databases; default financial
hive> show databases like 'f.*' financial上面的例子用来显示以f开头的那些数据库名。
hive> create database financial location '/user/hive/mywarehouse';用户也可以给这个数据库增加一个描述信息。语句如下:
hive> create databases financial comment 'Holds all financial tables';可以通过如下语句来查看数据库的描述信息:
hive>describe database financial; financial Holds all financial tables hdfs://master-server/user/hive/warehouse/financial.db可以通过下面语句来切换数据库:
hive> use financial; ... hive> use default; ...
hive> drop database if exists financial;
hive> drop database if exists financial cascade;
hive> alter database financials set dbproperties('created by' = 'aaron')
create table if not exists financial.employee ( name string, age tinyint, salary float, subordinates array<string>, address struct<country:string,province:string,city:string,street:string> );
hive> use financial; hive> show tables; employee
hive> use default; hive> show tables in financial; employee
hive> use financial; hive> show tables like 'emp.*'; employee
标签:des style blog http io color ar 使用 sp
原文地址:http://blog.csdn.net/iam333/article/details/40897445