内部表 :
创建表:
hive> create table wyp(id int,
name string,
age int,
tele string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\t’
STORED AS TEXTFILE;
OK
Time taken: 0.759 seconds
导入表:
做了以下几个步骤:
1.将本地的文件导入HDFS
2.将HDFS文件导入HVIE储存表的位置:/user/hive/warehouse/wyp(此路径是${HIVE_HOME}/conf/hive-site.xml配置文件的hive.metastore.warehouse.dir属性指向的路径),并以表明创建一个文件夹,存放次表的数据
hive> load data local inpath ‘/home/wyp/data/wyp.txt’ into table wyp;
Copying data from file:/home/wyp/data/wyp.txt
Copying file: file:/home/hdfs/wyp.txt
Loading data to table default.wyp
Table default.wyp stats: [num_partitions: 0, num_files: 1,
num_rows: 0, total_size: 67, raw_data_size: 0]
OK
Time taken: 3.289 seconds
hive> select * from wyp;
OK
1 wyp 25 13188888888888
2 test 30 13888888888888
3 zs 34 899314121
Time taken: 0.41 seconds, Fetched: 3 row(s)
2.外部表:
创建可以指定hive表存放的位置 > location ‘/home/wyp/external’;
hive> create external table exter_table(
id int,
name string,
age int,
tel string)
location ‘/home/wyp/external’;
OK
Time taken: 0.098 seconds
删除的时候,内部表 将文件移动到hdfs://mycluster/user/hdfs/.Trash/Current
hive> drop table wyp;
Moved: ‘hdfs://mycluster/user/hive/warehouse/wyp’ to
trash at: hdfs://mycluster/user/hdfs/.Trash/Current
OK
Time taken: 2.503 seconds
外部表只是删除元数据