List Databases, Tables and Display the Structure of a table using SQOOP
//Display all the databases
sqoop list-databases \
-connect "jdbc:mysql://localhost:3306/" \
-username root \
-password cloudera
firehose
hue
metastore
mysql
nav
navms
ohm
oozie
retail_db
rman
sentry
//Display all the tables in a database:
sqoop list-tables \
-connect "jdbc:mysql://localhost:3306/retail_db" \
-username root \
-password cloudera
categories
customers
departments
order_items
orders
products
suppliers
//Do evalute some queries
sqoop eval \
-connect "jdbc:mysql://localhost:3306/retail_db" \
-username root \
-password cloudera \
-query "describe customers"
---------------------------------------------------------------------------------------------------------
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------------------------------------------------------------
| customer_id | int(11) | NO | PRI | (null) | auto_increment |
| customer_fname | varchar(45) | NO | | (null) | |
| customer_lname | varchar(45) | NO | | (null) | |
| customer_email | varchar(45) | NO | | (null) | |
| customer_password | varchar(45) | NO | | (null) | |
| customer_street | varchar(255) | NO | | (null) | |
| customer_city | varchar(45) | NO | | (null) | |
| customer_state | varchar(45) | NO | | (null) | |
| customer_zipcode | varchar(45) | NO | | (null) | |
---------------------------------------------------------------------------------------------------------
sqoop eval \
-connect "jdbc:mysql://localhost:3306/retail_db" \
-username root \
-password cloudera \
-query "select min(customer_id) as Minn, max(customer_id) as Maxx from retail_db.customers"
-----------------------------
| Minn | Maxx |
-----------------------------
| 1 | 12435 |
-----------------------------
No comments:
Post a Comment