Sathish Santhosam
Sathish Santhosam

Reputation: 185

Hadoop Insert Without Select Clause

I'm New to Hadoop,i need to insert a record in a Table,When i search for syntax, every where the insert statement has values from select statement.

Is there a way to insert simple values with out Select statement?

Regards, Sathish.

Upvotes: 4

Views: 1864

Answers (1)

Dan Ciborowski - MSFT
Dan Ciborowski - MSFT

Reputation: 7207

First off I am guessing by the tag we are talking about HIVE.

When you are really using hive, you would never have a reason to add entries one at a time.

Easiest way to do this I think is to first create a CSV file with your data.

sample.csv
Dan,50
Dave,20
Sam,30

Then we place the file in hdfs

hadoop fs -copyFromLocal ./sample.csv /user/me/sample.csv

Now we go into hive and create our table with our data.

$ hive
hive> Create EXTERNAL TABLE IF NOT EXISTS sample(NAME STRING, Grade int)
hive> ROW FORMATED DELIMITED FILED TERMINATED BY ','
hive> STORED AS TEXTFILE location '/user/me/sample.csv';

Upvotes: 2

Related Questions