Database Reference
In-Depth Information
[Hadoop.testdomain:21000] > CREATE EXTERNAL
TABLE IF NOT EXIST motorcycles ( make STRING,
model STRING, year INTEGER, fuelType STRING,
wheels INTEGER, body STRING, style STRING,
cc_rpm INTEGER, highSpeed INTEGER, automatic
BOOLEAN, price FLOAT ) ROW FORMAT DELIMITED
FIELDS TERMINATED BY ',' STORED AS TEXTFILE
LOCATION '/user/cloudera/motorcycles' ;
Query: create EXTERNAL TABLE motorcycles ( make
STRING, model STRING, year INTEGER, fuelType
STRING, wheels INTEGER, body STRING, style
STRING, cc_rpm INTEGER, highSpeed INTEGER,
automatic BOOLEAN, price FLOAT ) ROW FORMAT
DELIMITED FIELDS TERMINATED BY ',' STORED AS
TEXTFILE LOCATION '/user/cloudera/motorcycles'
In the preceding command, we are creating an external table only if it does not exist.
And then we will pass the motorcycles text content from the text file to populate
the table.
Now, we can check the schema of the newly created motorcycles table using the
describe command as follows:
[Hadoop.testdomain:21000] > describe
motorcycles;
Query finished, fetching results ...
+-----------+---------+---------+
| name | type | comment |
+-----------+---------+---------+
| make | string | |
| model | string | |
| year | int | |
| fueltype | string | |
| wheels | int | |
| body | string | |
| style | string | |
| cc_rpm | int | |
Search WWH ::




Custom Search