Presto 0.141t Documentation

12.4. CREATE TABLE

12.4. CREATE TABLE

Synopsis

CREATE TABLE [ IF NOT EXISTS ]
table_name (
  column_name data_type [, ...]
)
[ WITH ( property_name = expression [, ...] ) ]

Description

Create a new, empty table with the specified columns. Use CREATE TABLE AS to create a table with data.

The optional IF NOT EXISTS clause causes the error to be suppressed if the table already exists.

The optional WITH clause can be used to set properties on the newly created table. To list all available table properties, run the following query:

SELECT * FROM system.metadata.table_properties

Examples

Create a new table orders:

CREATE TABLE orders (
  orderkey bigint,
  orderstatus varchar,
  totalprice double,
  orderdate date
)
WITH (format = 'ORC')

Create the table orders if it does not already exist:

CREATE TABLE IF NOT EXISTS orders (
  orderkey bigint,
  orderstatus varchar,
  totalprice double,
  orderdate date
)