...
Info | ||
---|---|---|
| ||
As of Hive 0.10.0 (HIVE-446) |
Syntax
Code Block |
---|
TRUNCATE TABLE table_name [PARTITION partition_spec]; partition_spec: : (partition_col = partition_col_value, partition_col = partiton_col_value, ...) |
...
Removes all rows from a table or partition(s).
...
Currently target table should be native/managed table
...
or exception will be thrown
...
.
Notes
User can specify partial partition spec for truncating multiple partitions at once
...
and omitting partition spec
...
will truncate all partitions in the table
...
.
Alter Table/Partition Statements
Alter table statements enable you to change the structure of an existing table. You can add columns/partitions, change serde, add table and serde properties, or rename the table itself. Similarly, alter table partition statements allow you change the properties of a specific partition in the named table.
...
This command will allow users to change a column's name, data type, comment, or position, or an arbitrary combination of them.
Example:
Code Block |
---|
CREATE TABLE test_change (a int, b int, c int); |
...
// will change column a's name to a1 |
...
ALTER TABLE test_change CHANGE a a1 |
...
INT; // will change column a's name to a1, a's data type to string, and put it after column b. The new table's structure is: b int, a1 string, c int |
...
ALTER TABLE test_change CHANGE |
...
a a1 STRING AFTER b; // will change column b's name to b1, and put it as the first column. The new table's structure is: b1 int, a string, c |
...
int
ALTER TABLE test_change CHANGE b b1 INT FIRST;
|
NOTE: The column change command will only modify Hive's metadata, and will NOT touch data. Users should make sure the actual data layout conforms with the metadata definition.
...