新建employees表
CREATE TABLE IF NOT EXISTS mydb.employees (
name STRING COMMENT 'Employee name',
salary FLOAT COMMENT 'Employee salary',
subordinates ARRAY<STRING> COMMENT 'Names of subordinates',
deductions MAP<STRING, FLOAT>
COMMENT 'Keys are deductions names, values are percentages',
address STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>
COMMENT 'Home address')
COMMENT 'Description of the table’
LOCATION '/user/hive/warehouse/mydb.db/employees’;
解释字段含义:
name:简单的字符串;salary是浮点型;
subordinates(下属雇员):是字符串数组;
deductions:一个由键值对构成的map,这是需要扣除的部分;
address:家庭住址,struct数据类型
复制表:可以复制一张已经存在的表结构(不包括数据)
hive> create table if not exists mydb.employees2 like mydb.employees;
create table if not exists mydb.employees2 like mydb.employees
OK
Time taken: 0.122 seconds
hive> show tables;
show tables
OK
employees
employees2
t
t1
Time taken: 0.064 seconds, Fetched: 4 row(s)
查看其他数据库表信息
若在default数据库中,要查看mydb数据库中的employees