C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Hive DDL CommandsCreate Database Statement A database in Hive is a namespace or a collection of tables. hive> CREATE SCHEMA userdb; hive> SHOW DATABASES; Drop database hive> DROP DATABASE IF EXISTS userdb; Creating Hive Tables Create a table called Sonoo with two columns, the first being an integer and the other a string. hive> CREATE TABLE Sonoo(foo INT, bar STRING); Create a table called HIVE_TABLE with two columns and a partition column called ds. The partition column is a virtual column. It is not part of the data itself but is derived from the partition that a particular dataset is loaded into.By default, tables are assumed to be of text input format and the delimiters are assumed to be ^A(ctrl-a). hive> CREATE TABLE HIVE_TABLE (foo INT, bar STRING) PARTITIONED BY (ds STRING); Browse the table hive> Show tables; Altering and Dropping Tables hive> ALTER TABLE Sonoo RENAME TO Kafka; hive> ALTER TABLE Kafka ADD COLUMNS (col INT); hive> ALTER TABLE HIVE_TABLE ADD COLUMNS (col1 INT COMMENT 'a comment'); hive> ALTER TABLE HIVE_TABLE REPLACE COLUMNS (col2 INT, weight STRING, baz INT COMMENT 'baz replaces new_col1');
Next TopicHive DML Commands
|