环境说明
OS : CentOs 6.4
mysql version : mysql-libs.zip 5.7.24
tips:Mysql和Hive安装在同一台Server上
方式1
创建表时,会生成目录/user/hive/warehouse/hive_test.db/name
如果表不存在则创建
create table IF not exists hive_test.name (
name string comment 'Your Name' ,
sex string , --列描述可不填写
age string comment 'Your age' ,
address string comment 'Your home address' )
comment 'School Student Information'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' --行中各列以逗号分隔
STORED AS TEXTFILE ; --默认TEXTFILE方式存储
默认表存储位置
--LOCATION '/user/hive/warehouse/hive_test.db/name'
加载如下数据到name表中
load data local inpath ‘/opt/data/name.txt’ into table hive_test.name;
drop table时,会删除hdfs数据
方式2
从已有的表结构中创建新表并拷贝数据
create table IF not exists hive_test.nameall
AS select name , age from hive_test.name ;
方式3
**从已有的表结构中创建新表,只创建表结构不拷贝数据 **
create table IF not exists hive_test.nameinfo
like hive_test.name ;