$cat>file1
My Name is Manohar.
Iam a Legend.
^C
create a table in customized location
-------------------------------------
create table tab1(line string)
location '/manohar/tables';
loading data
------------
hive>load data local inpath 'file1' into table tab1;
displaying data
---------------
hive>select *from tab1;
In hdfs
$hadoop fs -ls /manohar/tables
/manohar/tables/file1
examing data
------------
$hadoop fs -cat /manohar/tables/file1
My Name ..
Iam ....
dropping table
--------------
drop table tab1;
The path in hdfs is removed along with data if the table is inner table.
overwriting a table
-------------------
if we insert same file into a hive table reapeatedly then the data gets appended in the hive table.
ex:
cat > file1
My Name is Manohar!!!
^c
hive>create table tab5(line string);
hive>load data local inpath 'file1' into table tab5;
hive>load data local inpath 'file1' into table tab5;
hive>load data local inpath 'file1' into table tab5;
hive>select *from tab5;
My Name is Manohar!!!
My Name is Manohar!!!
My Name is Manohar!!!
Sometimes we should replace old files with new files in a hive table then we should use overwrite keyword with load command.
syntax
------
load data local inpath 'filename' overwrite into table tablename;
ex:
hive>load data local inpath 'file1' overwrite into table tab5;
hive>select *from tab5;
My Name is Manohar.
My Name is Manohar.
Iam a Legend.
^C
create a table in customized location
-------------------------------------
create table tab1(line string)
location '/manohar/tables';
loading data
------------
hive>load data local inpath 'file1' into table tab1;
displaying data
---------------
hive>select *from tab1;
In hdfs
$hadoop fs -ls /manohar/tables
/manohar/tables/file1
examing data
------------
$hadoop fs -cat /manohar/tables/file1
My Name ..
Iam ....
dropping table
--------------
drop table tab1;
The path in hdfs is removed along with data if the table is inner table.
overwriting a table
-------------------
if we insert same file into a hive table reapeatedly then the data gets appended in the hive table.
ex:
cat > file1
My Name is Manohar!!!
^c
hive>create table tab5(line string);
hive>load data local inpath 'file1' into table tab5;
hive>load data local inpath 'file1' into table tab5;
hive>load data local inpath 'file1' into table tab5;
hive>select *from tab5;
My Name is Manohar!!!
My Name is Manohar!!!
My Name is Manohar!!!
Sometimes we should replace old files with new files in a hive table then we should use overwrite keyword with load command.
syntax
------
load data local inpath 'filename' overwrite into table tablename;
ex:
hive>load data local inpath 'file1' overwrite into table tab5;
hive>select *from tab5;
My Name is Manohar.
No comments:
Post a Comment