Databases Reference
In-Depth Information
Next, create a table like so:
CREATE TABLE books (isbn INT, title STRING);
Available for
download on
Wrox.com
hive_examples.txt
This creates a table of books, with two columns: isbn and title . The column data types are
integer and string, respectively. To list the topics table's schema, query as follows:
hive> DESCRIBE books;
OK
Isbn int
Title string
Time taken: 0.263 seconds
Available for
download on
Wrox.com
hive_examples.txt
Create another table named users as follows:
CREATE TABLE users (id INT, name STRING) PARTITIONED BY (vcol STRING);
Available for
download on
Wrox.com
hive_examples.txt
The users table has three columns: id , name , and vcol . You can confi rm this running the DESCRIBE
table query as follows:
hive> DESCRIBE users;
OK
Id int
Name string
Vcol string
Time taken: 0.12 seconds
Available for
download on
Wrox.com
hive_examples.txt
The column vcol is a virtual column. It's a partition column derived from the partition in which the
data is stored and not from the data set itself. A single table can be partitioned into multiple logical
parts. Each logical part can be identifi ed by a specifi c value for the virtual column that identifi es the
partition.
Now run the SHOW TABLES command to list your tables like so:
hive> SHOW TABLES;
OK
books
users
Time taken: 0.087 seconds
Available for
download on
Wrox.com
hive_examples.txt
Search WWH ::




Custom Search