GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • V4.x Documentation
  • Contact
  • Privacy Statement
  • Contributor License Agreement
  • Software License Agreement
  • Trademarks

This view

  • Original page
  • New address

GeezerVison is showing docs.voltdb.com — CREATE VIEW

  • VoltDB Home
  • Forums
  • V4.x Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Performance Guide
    • VoltDB Planning Guide
    • VoltDB Administrator's Guide
  • Current docs ▶
CREATE VIEW

Documentation

VoltDB Home » Documentation » Using VoltDB
< previoustable of contentsnext >

CREATE VIEW

CREATE VIEW — Creates a view into a table, used to optimize access to specific columns within a table.

Synopsis

CREATE VIEW view-name ( view-column-name [,...] )
AS SELECT { column-name | selection-expression } [AS alias] [,...]
FROM table-name
[WHERE [NOT] boolean-expression [ {AND | OR} [NOT] boolean-expression]...]
GROUP BY { column-name | selection-expression } [,...]

Description

The CREATE VIEW statement creates a view of a table with selected columns and aggregates. VoltDB implements views as materialized views. In other words, the view is stored as a special table in the database and is updated each time the corresponding database table is modified. This means there is a small, incremental performance impact for any inserts or updates to the table, but selects on the view will execute efficiently.

The following limitations are important to note when using the CREATE VIEW statement with VoltDB:

  • Views are allowed on individual tables only. Joins are not supported.

  • The SELECT statement must obey the following constraints:

    • There must be a GROUP BY clause in the SELECT statement.

    • All of the columns and selection expressions listed in the GROUP BY must be listed in the same order at the start of the SELECT statement.

    • SELECT must include a field specified as COUNT(*). Other aggregate functions (COUNT, MAX, MIN, and SUM) are allowed following the COUNT(*).

Example

The following example defines a view that counts the number of records for a specific product item grouped by its location (that is, the warehouse the item is in).

CREATE VIEW inventory_count_by_warehouse (
     productID,
     warehouse,
     total_inventory
) AS SELECT
     productID,
     warehouse,
     COUNT(*)
FROM inventory GROUP BY productID, warehouse;
< previoustable of contentsnext >
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.