International: 1.408.916.4121
www.hortonworks.com
Twitter: twitter.com/hortonworks
Facebook: facebook.com/hortonworks
We Do Hadoop!
!
Query
SELECT&from_columns&FROM&table&WHERE&conditions;&
SELECT&from_columns&FROM&table&WHERE&conditions;&
SELECT&*&FROM&table&WHERE&rec_name&=&“value”;&
SELECT&*&FROM&table&WHERE&rec_name&=&"value";&
&
SELECT&*&FROM&table&WHERE&rec1=”value1”&AND&
rec2=”value2”;&
SELECT&*&FROM&TABLE&WHERE&rec1&=&"value1"&AND&
rec2&=&"value2";&
&
Selecting specific columns
SELECT&column_name&FROM&table;&
SELECT&column_name&FROM&table;&
&
Retrieving unique output records
SELECT&DISTINCT&column_name&FROM&table;&
SELECT&DISTINCT&column_name&FROM&table;&
&
SELECT&col1,&col2&FROM&table&ORDER&BY&col2;&
SELECT&col1,&col2&FROM&table&ORDER&BY&col2;&
&
SELECT&col1,&col2&FROM&table&ORDER&BY&col2&DESC;&
SELECT&col1,&col2&FROM&table&ORDER&BY&col2&DESC;&
&
SELECT&COUNT(*)&FROM&table;&
SELECT&COUNT(*)&FROM&table;&
&
SELECT&owner,&COUNT(*)&FROM&table&GROUP&BY&
owner;&
SELECT&owner,&COUNT(*)&FROM&table&GROUP&BY&
owner;&
&
SELECT&MAX(col_name)&AS&label&FROM&table;&
SELECT&MAX(col_name)&AS&label&FROM&table;&
&
Selecting from multiple tables
(Join same table using alias
w/”AS”)
SELECT&pet.name,&comment&FROM&pet,&event&WHERE&
pet.name&=&event.name;&
SELECT&pet.name,&comment&FROM&pet&JOIN&event&ON&
(pet.name&=&event.name);&
&
!
!
Metadata
!
Listing tables in a database
Describing the format of a table
DESCRIBE&(FORMATTED|EXTENDED)&table;&
CREATE&DATABASE&db_name;&
CREATE&DATABASE&db_name;&
DROP&DATABASE&db_name&(CASCADE);&
!
!