0
0
Hadoopdata~20 mins

Creating databases and tables in Hadoop - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Hive Database and Table Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Hive query?
Consider the following Hive query to create a database and then list all databases. What will be the output of the SHOW DATABASES; command?
Hadoop
CREATE DATABASE IF NOT EXISTS sales_db;
SHOW DATABASES;
A["default"]
B["default", "sales_db"]
CSyntaxError
D[]
Attempts:
2 left
💡 Hint
Think about what databases exist by default and what happens when you create a new one.
data_output
intermediate
2:00remaining
How many tables are in the database after these commands?
Given the following Hive commands, how many tables will be listed in sales_db?
Hadoop
CREATE DATABASE IF NOT EXISTS sales_db;
USE sales_db;
CREATE TABLE IF NOT EXISTS customers (id INT, name STRING);
CREATE TABLE IF NOT EXISTS orders (order_id INT, customer_id INT);
SHOW TABLES;
ASyntaxError
B0
C1
D2
Attempts:
2 left
💡 Hint
Count how many tables you created in the database.
🔧 Debug
advanced
2:00remaining
Identify the error in this Hive table creation command
What error will this Hive query produce?
Hadoop
CREATE TABLE employees (id INT, name STRING, salary);
ASyntaxError: Missing data type for column 'salary'
BNo error, table created successfully
CTypeError: Invalid column name
DRuntimeError: Table already exists
Attempts:
2 left
💡 Hint
Check if all columns have data types specified.
🧠 Conceptual
advanced
2:00remaining
What is the difference between EXTERNAL and MANAGED tables in Hive?
Choose the correct statement about EXTERNAL and MANAGED tables in Hive.
ADropping a MANAGED table deletes both metadata and data; dropping an EXTERNAL table deletes only metadata.
BDropping an EXTERNAL table deletes both metadata and data; dropping a MANAGED table deletes only metadata.
CBoth EXTERNAL and MANAGED tables delete data when dropped.
DNeither EXTERNAL nor MANAGED tables delete data when dropped.
Attempts:
2 left
💡 Hint
Think about who manages the data files for each table type.
🚀 Application
expert
3:00remaining
Which command creates a partitioned table in Hive?
You want to create a table named sales partitioned by year and month. Which Hive command correctly creates this partitioned table?
ACREATE TABLE sales PARTITIONED BY (year INT, month INT) (id INT, amount FLOAT);
BCREATE TABLE sales (id INT, amount FLOAT, year INT, month INT) PARTITIONED BY ();
CCREATE TABLE sales (id INT, amount FLOAT) PARTITIONED BY (year INT, month INT);
DCREATE TABLE sales (id INT, amount FLOAT) PARTITION (year INT, month INT);
Attempts:
2 left
💡 Hint
Remember the syntax for partitioned tables in Hive: columns go first, then PARTITIONED BY clause.