O'Reilly logo

Amazon Redshift: A Columnar Database SQL and Architecture by David Cook, Tom Coffing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5 – Temporary Tables

“They can conquer who believe they can.”

- Rita Rudner

Create Table Syntax

CREATE [ [LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name

( { column_name data_type [column_attributes] [ column_constraints ]

| table_constraints

| LIKE parent_table [ { INCLUDING | EXCLUDING } DEFAULTS ] }

[, ... ] )

[table_attribute]

where column_attributes are:

[ DEFAULT default_expr ]

[ IDENTITY ( seed, step ) ]

[ ENCODE encoding ]

[ DISTKEY ]

[ SORTKEY ]

and column_constraints are:

[ { NOT NULL | NULL } ]

[ { UNIQUE | PRIMARY KEY } ]

[ REFERENCES reftable [ ( refcolumn ) ] ]

and table_constraints are:

[ UNIQUE ( column_name [, ... ] ) ]

[ PRIMARY KEY ( column_name [, ... ] ) ]

[ FOREIGN KEY (column_name [, ... ] ) REFERENCES reftable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required