hive 定义库

2019-06-12  本文已影响0人  哈斯勒
每个数据库在hdfs都对应一个文件夹:
hive> create database hive_db;

hive> create database hive_db.test(id int);

hive> create database hive_db3 location '/hive_db3.db';

[root@big01 root]# hadoop fs -ls /
drwxr-xr-x   - root supergroup          0 2019-06-12 18:05 /hive_db3.db

hive> create database if not exists hive_db;

hive> show databases like "hive*";
OK
hive_db
hive_db3
Time taken: 0.203 seconds, Fetched: 2 row(s)

hive> alter database hive_db set dbproperties("CTtime"="2020=06-22");
OK
Time taken: 0.241 seconds

hive> desc database extended hive_db;
OK
hive_db         hdfs://192.168.50.153:9000/user/hive/warehouse/hive_db.db       root    USER    {CTtime=2020=06-22}
Time taken: 0.202 seconds, Fetched: 1 row(s)

删除空表
hive> drop database hive_db3;
OK
Time taken: 0.453 seconds

删除非空表
hive> drop database if exists hive_db cascade;
OK
Time taken: 0.488 seconds


生成表语法:
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]
上一篇下一篇

猜你喜欢

热点阅读