Live aggregate projection
Stores the grouped results of queries that invoke aggregate functions (such as SUM) on table columns. For details, see Live aggregate projections.
Syntax
CREATE PROJECTION [ IF NOT EXISTS ] [[database.]schema.]projection
[ (
{ projection-column | grouped-clause
[ ENCODING encoding-type ]
[ ACCESSRANK integer ] }[,...]
) ]
AS SELECT { table-column | expr-with-table-columns }[,...] FROM [[database.]schema.]table [ [AS] alias]
GROUP BY column-expr
[ KSAFE [ k-num ] ]
Parameters
IF NOT EXISTSIf an object with the same name exists, do not create it and proceed. If you omit this option and the object exists, Vertica generates a ROLLBACK error message. In both cases, the object is not created if it already exists.
The
IF NOT EXISTSclause is useful for SQL scripts where you want to create an object if it does not already exist.For related information, see ON_ERROR_STOP.
[database.]schemaSpecifies the schema for this projection and its anchor table, where
schemamust be the same for both. If you specify a database, it must be the current database.projectionIdentifies the projection to create, where
projectionconforms to conventions described in Identifiers. It must also be unique among all names of sequences, tables, projections, views, and models within the same schema.projection-columnThe name of a projection column. The list of projection columns must match the SELECT list columns and expressions in number, type, and sequence.
If projection column names are omitted, Vertica uses the anchor table column names specified in the SELECT list.
grouped-clause- See GROUPED clause.
ENCODINGencoding-typeThe column encoding type, by default set to AUTO.
ACCESSRANKintegerOverrides the default access rank for a column. Use this parameter to increase or decrease the speed at which Vertica accesses a column. For more information, see Overriding Default Column Ranking.
AS SELECTSpecifies the table data to query:
{table-column | expr-with-table-columns } [ [AS] alias] }[,...]You can optionally assign an alias to each column expression and reference that alias elsewhere in the SELECT statement.
Note
If you specify projection column names, the two lists of projection columns and table columns/expressions must exactly match in number and order.GROUP BYcolumn-expr[,...]- One or more column expressions from the SELECT list. The first
column-exprmust be the first column expression in the SELECT list, the secondcolumn-exprmust be the second column expression in the SELECT list, and so on.
Privileges
Non-superusers:
-
Anchor table owner
-
CREATE privilege on the schema
Requirements and restrictions
Vertica does not regard live aggregate projections as superprojections, even those that include all table columns. For other requirements and restrictions, see Creating live aggregate projections.