HiveSql语句(1)

1.创建表时array类型的数据列需要写成ARRAY,如下图:
HiveSql语句(1)_第1张图片

2.听说hive没有主键的概念?

3.hive建表时设置存储格式:

create table database.tablename (
    id int,
    name string,
    age int
    birthday timestamp
) comment 'tablename' row format delimited fields terminated by '\t' lines terminated by '\n';
  1. hive本地文件数据导入表命令:
    load data local inpath '../a.txt' [overwrite] into table tablename

5.hive 不支持select * from tablename group by columnname,
需要用join on连接。

select * from tablename t1 join (
    select columnname from tablename group by columnname having ...
) t2 on t1.columnname=t2.columnname;

6.hive没有exists关键字,需要用left semi join代替,join子句中右边的表只能在on子句中设置过滤条件,在where子句、select子句或其他地方过滤都不行。

select * from tablename left semi join (
    select * from tablename 
) t2 on t2.columnname = value;

你可能感兴趣的:(数据库)