Thomas
Thomas

Reputation: 370

Can I create a Hive table from a file like we do in MySQL

Can I create a Hive table from a sql/text file like we do in the case of MySQL and other RDBMSs. That is, store the "create table..." command in a .sql file and execute it in one go.

For eg. in MySQL I can do this

shell> mysql < sql_file

or if you are already running mysql,

mysql> source sql_file

1) Is there any such option in Hive

2) If yes, what would be the command and what would be the file extension

thanks

Upvotes: 0

Views: 2297

Answers (2)

Sandeep Choudhary
Sandeep Choudhary

Reputation: 376

  1. Write a scirpt in a file with .sql extension. Like HiveScript.sql
  2. Ensure that hive is working properly by using hive command and see whether hive shell is open or not.
  3. Run hive -f HiveScript.sql

Upvotes: 0

Sandeep
Sandeep

Reputation: 546

You can use $HIVE_HOME/bin/hive -f /home/my/hive-script.sql from terminal. Refer to hive documentation link https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Cli .

Upvotes: 3

Related Questions