This shows you the differences between two versions of the page.
— |
create-table [2015/09/23 20:27] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== CREATE TABLE Statement - PL/HQL ====== | ||
+ | CREATE TABLE statement create a table in the database. | ||
+ | |||
+ | **Syntax**: | ||
+ | |||
+ | <code language=sql> | ||
+ | CREATE TABLE [IF NOT EXISTS] table_name | ||
+ | ( | ||
+ | column_name data_type [NULL | NOT NULL] | ||
+ | [, constraint ...] | ||
+ | [, ...] | ||
+ | ) | ||
+ | </code> | ||
+ | |||
+ | ===== CREATE TABLE Conversion ===== | ||
+ | |||
+ | If the CREATE TABLE statement is defined using the syntax not supported by Hive, it is automatically converted to conform to Hive syntax. | ||
+ | |||
+ | Currently PL/HQL converts data types, removes NOT NULL/NULL, constraints and default values. For more information, see [[conversion|On-the-Fly Conversion]] | ||
+ | |||
+ | **Example**: | ||
+ | |||
+ | Convert SQL and create a table in Hive: | ||
+ | |||
+ | <code language=sql> | ||
+ | CREATE TABLE dept ( | ||
+ | deptno NUMBER(2,0), | ||
+ | dname NUMBER(14), | ||
+ | loc VARCHAR2(13), | ||
+ | CONSTRAINT pk_dept PRIMARY KEY (deptno) | ||
+ | ); | ||
+ | </code> | ||
+ | |||
+ | **Compatibility:** Oracle, Microsoft SQL Server, IBM DB2, Teradata, PostgreSQL, MySQL and Netezza | ||
+ | |||
+ | **Version**: PL/HQL 0.03 | ||
+ | |||
+ | ~~NOTOC~~ |