Database Reference
In-Depth Information
postalCode STRING,
purchases MAP<STRING, DECIMAL>);
WARNING
Using
ALTER TABLE
to modify a table changes the metadata for the
table. It does not modify the data in the files. This option is useful for
correcting mistakes in the schema for a table, but any data issues have
to be cleaned up separately.
As discussed in the “Custom File and Record Formats” section, Hive gives
you control over the record format. In the preceding
CREATE TABLE
statement, the Hive defaults are used; it expects text files in delimited
format, with
Ctrl-A
(octal
001
) as a field delimiter. To control that format,
Hive supports explicitly declaring the format options. The preceding table,
with explicit delimiters defined, would look like this:
CREATE TABLE MsBigData.customer (
name STRING,
city STRING,
state STRING,
postalCode STRING,
purchases MAP<STRING, DECIMAL>
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
COLLECTION ITEMS TERMINATED BY '\002'
MAP KEYS TERMINATED BY '\003'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;
The file format is controlled by the
STORED AS
portion of the statement.
To use the
SEQUENCEFILE
file format, you replace
STORED AS TEXTFILE
with
STORED AS SEQUENCEFILE
. To use custom file formats, you specify
the
INPUTFORMAT
and
OUTPUTFORMAT
options directly. For example, here
isthespecificationforthe
RCFile
format.Thevalueinthestringistheclass
name for the file format to be used: