Book Contents

Book Index

Next Topic

Home

CREATE PROJECTION

The CREATE PROJECTION command creates metadata for a projection in the Vertica catalog. It does not load data into physical storage unless the tables(s) over which the projection is defined already contain data. In that case, the new projection becomes available as soon as the database has automatically refreshed it. This process may take a long time, depending on how much data is in the table(s).

Use CREATE PROJECTION only when advised to do so by Technical Support. Improper use can corrupt data and/or damage a database.

Syntax

CREATE PROJECTION projection-name

( projection-column [ ENCODING encoding-type ] [ , ... ] )

AS SELECT table-column [ , ... ]

FROM table-reference [ , ... ]

[ WHERE join-predicate [ AND join-predicate ] ...

[ ORDER BY table-column [ , ... ] ]

[ hash-segmentation-clause | range-segmentation-clause

| UNSEGMENTED { NODE node | ALL NODES } ]

Semantics

projection-name

specifies the name of the projection (see note below).

projection-column

specifies the name of a column in the projection. The data type is inferred from the corresponding column in the schema table (based on ordinal position). Different projection-column names can be used to distinguish multiple columns of the same name from different tables so that no aliases are needed.

encoding-type

specifies the type of encoding to use on the column. The Database Designer automatically chooses an appropriate encoding for each projection column.

SELECT table-column

specifies a list of schema table columns corresponding (in ordinal position) to the projection columns.

table-reference

specifies a list of schema tables containing the columns to include in the projection in the form:

table-name [ AS ] alias [ ( column-alias [ , ...] ) ] [ , ...] ]

WHERE join-predicate

specifies foreign-key = primary-key equijoins between the fact table and dimension tables. Foreign key columns must be NOT NULL. No other predicates are allowed.

ORDER BY table-column

specifies which columns to sort. Because all projection columns are sorted in ascending order in physical storage, CREATE PROJECTION does not allow you to specify ascending or descending.

hash-segmentation-clause

allows you to segment a projection based on a built-in hash function that provides even distribution of data across nodes, resulting in optimal query execution. See hash-segmentation-clause.

range-segmentation-clause

allows you to segment a projection based on a known range of values stored in a specific column chosen to provide even distribution of data across a set of nodes, resulting in optimal query execution. See range-segmentation-clause.

NODE node

creates an unsegmented projection on the specified node only. Dimension table projections must be UNSEGMENTED.

ALL NODES

creates a separate unsegmented projection on each node at the time the CREATE PROJECTION statement is executed (automatic replication). In order to do distributed query execution, Vertica requires an exact, unsegmented copy of each dimension table superprojection on each node. See projection naming note below.

Unsegmented Projection Naming

CREATE PROJECTION ... UNSEGMENTED takes a snapshot of the nodes defined at execution time to generate a node list in a predictable order. Thus, replicated projections have the name:

projection-name_node-name

For example, if the nodes are named NODE01, NODE02, and NODE03 then:

CREATE PROJECTION ABC ... UNSEGMENTED ALL NODES

creates projections named ABC_NODE01, ABC_NODE02, and ABC_NODE03.

This naming convention may impact functions that provide information about projections, for example, GET_TABLE_PROJECTIONS or GET_PROJECTION_STATUS where you will need to provide the name ABC_NODE01 instead of just ABC. To view a list of the nodes in a database, use the View Database command in the Administration Tools.

Notes

In This Section

encoding-type

hash-segmentation-clause

range-segmentation-clause