创建数据库
location指定HDFS中的存储位置、 comment为数据库添加备注信息、 with dbproperties添加一些属性比如创建者和创建时间
hive (default)> create database if not exists hive1
> comment 'mydatabase'
> location '/lyl'
> with dbproperties("creator"="lyl","date"="20180120");
OK
Time taken: 0.286 seconds
【如果不指定location默认是在/user/hive/warehouse】
创建表
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name
[(col_name data_type [COMMENT col_comment], ...)]
[COMMENT table_comment]
[PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)]
[CLUSTERED BY (col_name, col_name, ...)
[SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION hdfs_path]
说明: