CREATE TABLE¶
Synopsis¶
CREATE TABLE [ IF NOT EXISTS ]
table_name (
column_name data_type [ NOT NULL ]
[, ...]
)
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.
Column types are the Polars SQL scalar types documented in
Data Types. NOT NULL columns reject NULL input.
Examples¶
Create a new table orders:
CREATE TABLE orders (
orderkey bigint,
orderstatus varchar,
totalprice double,
orderdate date
)
Create the table orders if it does not already exist, with a not null
constraint on column orderstatus:
CREATE TABLE IF NOT EXISTS orders (
orderkey bigint,
orderstatus varchar NOT NULL,
totalprice double,
orderdate date
)