• Glossary
  • Support
  • Downloads
  • DataStax Home
Get Live Help
Expand All
Collapse All

CQL for DSE

  • Overview
    • Cassandra structure
    • About CQL
    • CQL quick reference
    • Known issues
  • Getting started
    • Vector Search Quickstart
    • CQL Quickstart
    • SAI Quickstart
    • DSE Search Indexing Quick Start
  • Planning
    • Data modeling
      • Data modeling concepts
      • Data modeling analysis
  • Connecting
    • cqlsh (startup options)
      • Accessing data using CQL
        • Starting the standalone cqlsh tool
        • Starting cqlsh
    • Developing
      • Introduction to CQL
      • Managing keyspaces
        • Keyspace concepts
        • Create a keyspace
        • Check a keyspace
        • Alter a keyspace
        • Drop a keyspace
      • Managing tables
        • Table concepts
        • Data types
        • Create a table
        • Check a table
        • Alter a table
        • Truncate a table
        • Drop a table
      • Managing columns
        • Managing columns
        • Create a table column
        • Check column existence
        • Alter a table column
        • Drop a column
        • User-defined type (UDT) overview
          • Create a user-defined type (UDT)
          • Check for user-defined type (UDT) existence
          • Alter a user-defined type (UDT)
          • Drop a user-defined type (UDT)
        • User-defined functions (UDFs) and user-defined aggregates (UDAs) overview
          • Create a user-defined function (UDF)
          • Check a user-defined function (UDF)
          • Drop a user-defined function (UDF)
          • Create a user-defined aggregate function (UDA)
          • Checking a user-defined aggregate (UDA)
          • Drop a user-defined aggregate (UDA)
      • Managing Materialized views
        • Materialized views concepts
        • Known limitations of materialized views
        • Create a materialized view (MV)
        • Alter a materialized view (MV)
        • Drop a materialized view
        • Frequently asked questions about materialized views
      • Indexing Tables
        • Indexing concepts
        • Storage-Attached Indexing (SAI) Overview
          • SAI concepts
          • SAI Quickstart
          • SAI FAQ
          • Create SAI index
          • Alter SAI index
          • Drop SAI index
          • Querying with SAI
          • Configure SAI indexes
          • Monitor SAI indexes
          • SAI write path and read path
        • Secondary indexes (2i) overview
          • Secondary index (2i) concepts
          • When to use an index
          • Building and maintaining secondary indexes (2i)
          • Create a secondary index (2i)
            • Create a 2i on a collection column
          • Check secondary index (2i) existence
          • Alter a secondary index (2i)
          • Drop a secondary index (2i)
        • Search indexes overview
          • Search index commands
          • Adjusting timeout for index management
          • Creating a search index
          • Configuring search index joins
          • Joining cores
          • Reloading the search index
          • Removing a search index
          • Managing search index fields
            • Syntax for changing schema settings
            • Search index schema field types
            • Adding a new field type
            • Adding a column to the index
            • Indexing tuples and UDTs fields
              • Tuple configuration example
              • UDT configuration example
              • Nesting tuples and UDTs
              • Tuples and UDTs as CQL map values
            • Indexing map columns
            • Indexing a column for different analysis
            • Dropping columns from the index
          • Updating the index after data expires (TTL)
          • Inserting, updating, and deleting data
          • Search indexing examples
        • Search index examples
          • Search index examples
            • Creating a demo keyspace for tutorials
            • Indexing and querying polygons
      • Inserting and updating data
        • Insert simple data
        • Set column
        • List fields
        • Map fields
        • Tuple
        • User-defined type (UDT) column
        • Insert static data
        • UUID and timeuuid column
        • Date column
        • Time column
        • Timestamp column
        • Duration column
        • Update counter
        • Lightweight transactions (LWTs)
        • Inserting JSON formatted values
        • Batching inserts and updates
          • Batching inserts, updates, and deletes
          • Good use of BATCH statement
          • Misuse of BATCH statement
        • Importing data from a CSV file
        • Setting the time-to-live (TTL) for value
          • Inserting, updating, and deleting data
      • Deleting data
        • Deleting values from a column or entire row
        • Expiring data with time-to-live
        • Expiring data with TTL example
      • Querying and retrieving data
        • Using a SELECT statement
        • Restricting queries using WHERE clauses
          • Partition keys
          • Clustering columns
          • Retrieval using the IN keyword
          • Sorting and limiting results
        • Returning data from collection columns
        • Aggregating results
        • Using user-defined functions (UDF)
        • Applying user-defined aggregate (UDA) functions
          • Testing performance impact using tracing
        • Formatting query results as JSON
        • Retrieving the write timestamp
        • Using tracing
          • Tracing performance
        • DSE Search index querying
        • Search index filtering best practices
          • Search index syntax
          • search-index:si-query-syntax.adoc#siIndexedColumns
          • search-index:si-query-syntax.adoc#basicSolrSyntax
          • search-index:si-query-syntax.adoc#queriesJSON
          • search-index:si-query-syntax.adoc#siEscapeCharacters
        • Native CQL search queries
        • Identifying the partition key
        • Filtering on terms
          • Filtering on words, phrases, or substrings
          • Fuzzy search
        • UDT query examples
        • Querying a CQL collection set
        • Using date ranges in solr_query
        • Geospatial queries for Point and LineString
        • Spatial queries with polygons require JTS
        • Using dynamic fields
        • Limiting results and paging
        • Restricted query routing
    • Securing overview
      • Security quickstart
      • Using cqlsh with authentication
      • System tables for authentication and authorization
  • Cycling Examples
    • Setting up the cycling keyspace
    • User-defined types (UDTs)
      • basic_info
      • basic_info_withTTL
      • fullname
      • race
    • User-defined functions (UDFs) and user-defined aggregates (UDAs)
      • flog
      • left
      • average_state
      • average_final
      • Cycling user-defined aggregate team_average
    • Tables
      • birthday_list
      • calendar
      • comments
      • country_flag
      • cyclist_alt_stats
      • cyclist_base
      • cyclist_career_teams
      • cyclist_category
      • cyclist_emails
      • cyclist_expenses
      • cyclist_id
      • cyclist_name
      • cyclist_points
      • cyclist_races
      • cyclist_sponsors
      • cyclist_stats
      • cyclist_teams
      • events
      • popular_count
      • race_sponsors
      • race_starts
      • race_times
      • race_winners
      • rank_by_year_and_name
      • team_average
      • upcoming_calendar
    • Materialized views (MVs)
      • cyclist_by_age-mv
    • Search indexes
      • Search index examples
      • comments search index
    • SASI indexes
      • Index on cyclist_name
    • Access control
      • Cycling internal
    • Cycling queries
      • Aggregating cycling data
    • Reference
      • CQL quick reference
      • Understanding the CQL command syntax
      • Data types
        • Creating a blob column
        • Date, time, and timestamp format
        • Solr field type reference for DSE Search
      • Operators
      • CQL native functions
      • CQL native aggregates
      • System and virtual tables
        • System tables
          • Keyspace tables
          • Querying system tables
          • Functions, aggregates, and user types
        • Virtual tables
          • Virtual keyspaces and tables
          • Virtual tables for SAI indexes and SSTables
      • cqlsh (startup options)
        • Configuring a cqlshrc file
        • Starting cqlsh on a search node
      • CQL shell (cqlsh) reference
        • CAPTURE
        • CLEAR
        • CONSISTENCY
        • COPY TO
        • COPY FROM
        • DESCRIBE AGGREGATE
        • DESCRIBE CLUSTER
        • DESCRIBE SCHEMA
        • DESCRIBE FUNCTION
        • DESCRIBE INDEX
        • DESCRIBE KEYSPACE
        • DESCRIBE MATERIALIZED VIEW
        • DESCRIBE SEARCH INDEX
        • DESCRIBE TABLE
        • DESCRIBE TYPE
        • EXECUTE AS
        • EXPAND
        • EXIT
        • LOGIN
        • PAGING
        • SERIAL CONSISTENCY
        • SHOW
        • SOURCE
        • TIMING
        • TRACING
      • CQL commands
        • ALTER KEYSPACE
        • ALTER MATERIALIZED VIEW
        • ALTER ROLE
        • ALTER SEARCH INDEX CONFIG
        • ALTER SEARCH INDEX SCHEMA
        • ALTER TABLE
        • ALTER TYPE
        • ALTER USER (Deprecated)
        • BATCH
        • COMMIT SEARCH INDEX
        • CREATE AGGREGATE
        • CREATE CUSTOM INDEX
        • CREATE FUNCTION
        • CREATE INDEX
        • CREATE KEYSPACE
        • CREATE MATERIALIZED VIEW
        • CREATE ROLE
        • CREATE SEARCH INDEX
        • CREATE TABLE
        • CREATE TYPE
        • CREATE USER (Deprecated)
        • DELETE
        • DROP AGGREGATE
        • DROP FUNCTION
        • DROP INDEX
        • DROP KEYSPACE
        • DROP MATERIALIZED VIEW
        • DROP ROLE
        • DROP SEARCH INDEX
        • DROP TABLE
        • DROP TYPE
        • DROP USER (Deprecated)
        • GRANT
        • INSERT
        • LIST PERMISSIONS
        • LIST ROLES
        • LIST USERS (Deprecated)
        • REBUILD SEARCH INDEX
        • RELOAD SEARCH INDEX
        • RESTRICT
        • RESTRICT ROWS
        • REVOKE
        • SELECT
        • TRUNCATE
        • UNRESTRICT
        • UNRESTRICT ROWS
        • UPDATE
        • USE
  • CQL for DSE
  • Reference
  • CQL commands
  • CREATE MATERIALIZED VIEW
Edit this Page

CREATE MATERIALIZED VIEW

Optimizes read requests by allowing different partitioning and clustering columns than the base table and eliminates the need for individual write requests to multiple tables. When data is written to the base table, it is also automatically written to all associated materialized views.

Restriction:

  • Use all base table primary keys in the materialized view.

  • Multiple non-primary key columns from the base table are supported when the partition key is the same as in the base table, otherwise only a single non-primary key from the base table is allowed in the materialized view’s PRIMARY KEY.

  • Static columns are not supported.

  • Exclude rows with null values in the materialized view primary key column.

  • A materialized view cannot be created in a different keyspace from the base table. You also cannot create a materialized view in the system tables.

Synopsis

CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] [<keyspace_name>.]<view_name>
  AS SELECT [ (<column_list>) ]
  FROM [<keyspace_name>.]<table_name>
  [ WHERE <column_name> IS NOT NULL
  [ AND <column_name> IS NOT NULL ... ] ]
  [ AND <relation> [ AND ... ] ]
  PRIMARY KEY ( <column_list> )
  [ WITH [ table_properties ]
  [ [ AND ] CLUSTERING ORDER BY (cluster_column_name <order_option>) ] ] ;
Syntax legend
Table 1. Legend
Syntax conventions Description

UPPERCASE

Literal keyword.

Lowercase

Not literal.

< >

Variable value. Replace with a user-defined value.

[]

Optional. Square brackets ([]) surround optional command arguments. Do not type the square brackets.

( )

Group. Parentheses ( ( ) ) identify a group to choose from. Do not type the parentheses.

|

Or. A vertical bar (|) separates alternative elements. Type any one of the elements. Do not type the vertical bar.

...

Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.

'<Literal string>'

Single quotation (') marks must surround literal strings in CQL statements. Use single quotation marks to preserve upper case.

{ <key> : <value> }

Map collection. Braces ({ }) enclose map collections or key value pairs. A colon separates the key and the value.

<datatype2

Set, list, map, or tuple. Angle brackets ( < > ) enclose data types in a set, list, map, or tuple. Separate the data types with a comma.

<cql_statement>;

End CQL statement. A semicolon (;) terminates all CQL statements.

[--]

Separate the command line options from the command arguments with two hyphens ( -- ). This syntax is useful when arguments might be mistaken for command line options.

' <<schema\> ... </schema\>> '

Search CQL only: Single quotation marks (') surround an entire XML schema declaration.

@<xml_entity>='<xml_entity_type>'

Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files.

IF NOT EXISTS

Optional. Suppresses the error message when attempting to create a materialized view that already exists. Use to continue executing commands, such as a SOURCE command. The option only validates that a materialized view with the same name exists; columns, primary keys, properties, and other settings can differ.

keyspace_name

Optional. When no keyspace is selected or to create the view in another keyspace, set the keyspace name before the materialized view name.

Base tables and materialized views are always in the same keyspace.

view_name

Materialized view names can only contain alpha-numeric characters and underscores. The view name must begin with a number or letter and can be up to 49 characters long.

column_list

Comma-separated list of columns from the base table to include in the materialized view.

Static columns, even when specified, are not supported and not included in the materialized view.

<column_name> IS NOT NULL

Test all columns for null values in the WHERE clause. Separate each condition with AND. Rows with null values in any column are not inserted into the materialized view table.

AND relation

Other relations that target the specific data needed.

PRIMARY KEY ( column_list )

Comma-separated list of columns used to partition and cluster the data. You can add non-primary key columns from the base table. Reorder the primary keys as needed to query the table more efficiently, including changing the partitioning and clustering keys.

List the partition key first, followed by the clustering keys. Create a compound partition key by enclosing column names in parenthesis, for example:

PRIMARY KEY (
  ( <PK_column1> [, <PK_column2>... ] ),
  <clustering_column1> [, <clustering_column2> ... ] )
<table_properties>

Optional. Specify table properties if different than default. Separate table property definitions with an AND. See table properties.

The base table properties are not copied.

Restriction: Change log, CDC, is not available for materialized views. Not all table properties are available when creating a materialized view; for example, default_time_to_live is not available.

Examples

This section shows example scenarios that illustrate the use of materialized views.

Basic examples of materialized views

These tables are used in the first example scenario:

CREATE TABLE IF NOT EXISTS cycling.cyclist_base (
  cid UUID PRIMARY KEY,
  name text,
  age int,
  birthday date,
  country text
);
CREATE TABLE IF NOT EXISTS cycling.cyclist_base_ext (
  cid UUID, 
  name text, 
  age int, 
  birthday date, 
  country text,
  PRIMARY KEY (cid, age, birthday)
);

The following materialized view cyclist_by_age uses the base table cyclist_base. The WHERE clause ensures that only rows whose age and cid columns are non-NULL are added to the materialized view. In the materialized view, age is the partition key, and cid is the clustering column. In the base table, cid is the partition key.

CREATE MATERIALIZED VIEW IF NOT EXISTS cycling.cyclist_by_age AS
  SELECT age, cid, birthday, country, name
  FROM cycling.cyclist_base 
  WHERE age IS NOT NULL
    AND cid IS NOT NULL
  PRIMARY KEY (age, cid)
  WITH CLUSTERING ORDER BY (cid ASC)
  AND caching = {
    'keys' : 'ALL',
    'rows_per_partition' : '100'
  }
  AND comment = 'Based on table cyclist';

The results of this query:

SELECT *
FROM cycling.cyclist_by_age;

are:

 age | cid                                  | birthday   | country       | name
-----+--------------------------------------+------------+---------------+---------------------
  28 | 6ab09bec-e68e-48d9-a5f8-97e6fb4c9b47 | 1987-06-07 |   Netherlands |   Steven KRUIKSWIJK
  19 | 1c526849-d3a2-42a3-bcf9-7903c80b3d16 | 1998-12-23 |     Australia |       Kanden GROVES
  19 | 410919ef-bd1b-4efa-8256-b0fd8ab67029 | 1999-01-04 |    Uzbekistan | Iskandarbek SHODIEV
  18 | 15a116fc-b833-4da6-ab9a-4a7775752836 | 1997-08-19 | United States |        Adrien COSTA
  18 | 18f471bf-f631-4bc4-a9a2-d6f6cf5ea503 | 1997-03-29 |   Netherlands |         Bram WELTEN
  18 | ffdfa2a7-5fc6-49a7-bfdc-3fcdcfdd7156 | 1997-02-08 |   Netherlands |    Pascal EENKHOORN
  22 | e7ae5cf3-d358-4d99-b900-85902fda9bb0 | 1993-06-18 |   New Zealand |          Alex FRAME
  27 | c9c9c484-5e4a-4542-8203-8d047a01b8a8 | 1987-09-04 |        Brazil |     Cristian EGIDIO
  27 | d1aad83b-be60-47a4-bd6e-069b8da0d97b | 1987-09-04 |       Germany |     Johannes HEIDER
  20 | 862cc51f-00a1-4d5a-976b-a359cab7300e | 1994-09-04 |       Denmark |       Joakim BUKDAL
  38 | 220844bf-4860-49d6-9a4b-6b5d3a79cbfb | 1977-07-08 |         Italy |     Paolo TIRALONGO
  29 | 96c4c40d-58c8-4710-b73f-681e9b1f70ae | 1989-04-20 |     Australia |     Benjamin DYBALL

(12 rows)

The following materialized view cyclist_by_birthday_and_age uses the base table cyclist_base. The WHERE clause ensures that only rows whose age, birthday, and cid columns are non-NULL are added to the materialized view. In the materialized view, cid is the partition key, birthday is the first clustering column, and age is the second clustering column. In the base table, cid is the partition key.

CREATE MATERIALIZED VIEW IF NOT EXISTS cycling.cyclist_by_birthday_and_age AS
  SELECT age, cid, birthday, country, name
  FROM cycling.cyclist_base
  WHERE age IS NOT NULL
    AND birthday IS NOT NULL
    AND cid IS NOT NULL
  PRIMARY KEY (cid, birthday, age);

The results of this query:

SELECT *
FROM cycling.cyclist_by_birthday_and_age;

are:

 cid                                  | birthday   | age | country       | name
--------------------------------------+------------+-----+---------------+---------------------
 ffdfa2a7-5fc6-49a7-bfdc-3fcdcfdd7156 | 1997-02-08 |  18 |   Netherlands |    Pascal EENKHOORN
 15a116fc-b833-4da6-ab9a-4a7775752836 | 1997-08-19 |  18 | United States |        Adrien COSTA
 e7ae5cf3-d358-4d99-b900-85902fda9bb0 | 1993-06-18 |  22 |   New Zealand |          Alex FRAME
 c9c9c484-5e4a-4542-8203-8d047a01b8a8 | 1987-09-04 |  27 |        Brazil |     Cristian EGIDIO
 410919ef-bd1b-4efa-8256-b0fd8ab67029 | 1999-01-04 |  19 |    Uzbekistan | Iskandarbek SHODIEV
 d1aad83b-be60-47a4-bd6e-069b8da0d97b | 1987-09-04 |  27 |       Germany |     Johannes HEIDER
 862cc51f-00a1-4d5a-976b-a359cab7300e | 1994-09-04 |  20 |       Denmark |       Joakim BUKDAL
 1c526849-d3a2-42a3-bcf9-7903c80b3d16 | 1998-12-23 |  19 |     Australia |       Kanden GROVES
 18f471bf-f631-4bc4-a9a2-d6f6cf5ea503 | 1997-03-29 |  18 |   Netherlands |         Bram WELTEN
 220844bf-4860-49d6-9a4b-6b5d3a79cbfb | 1977-07-08 |  38 |         Italy |     Paolo TIRALONGO
 6ab09bec-e68e-48d9-a5f8-97e6fb4c9b47 | 1987-06-07 |  28 |   Netherlands |   Steven KRUIKSWIJK
 96c4c40d-58c8-4710-b73f-681e9b1f70ae | 1989-04-20 |  29 |     Australia |     Benjamin DYBALL

(12 rows)

The following materialized view cyclist_by_country_and_birthday uses the base table cyclist_base. The WHERE clause ensures that only rows whose birthday and cid columns are non-NULL and country equals Australia are added to the materialized view.

CREATE MATERIALIZED VIEW IF NOT EXISTS cycling.cyclist_by_country_and_birthday AS
  SELECT age, cid, birthday, country, name
  FROM cycling.cyclist_base
  WHERE birthday IS NOT NULL
    AND cid IS NOT NULL
    AND country = 'Australia'
  PRIMARY KEY (cid, country, birthday);

The results of this query:

SELECT *
FROM cycling.cyclist_by_country_and_birthday;

are:

 cid                                  | country   | birthday   | age | name
--------------------------------------+-----------+------------+-----+-----------------
 1c526849-d3a2-42a3-bcf9-7903c80b3d16 | Australia | 1998-12-23 |  19 |   Kanden GROVES
 96c4c40d-58c8-4710-b73f-681e9b1f70ae | Australia | 1989-04-20 |  29 | Benjamin DYBALL

(2 rows)

The following materialized view cyclist_by_birthday_and_age19 uses the base table cyclist_base. The WHERE clause ensures that only rows whose birthday and cid columns are non-NULL and age equals the value 19 are added to the materialized view.

CREATE MATERIALIZED VIEW IF NOT EXISTS cycling.cyclist_by_birthday_and_age19 AS
  SELECT age, cid, birthday, country, name
  FROM cycling.cyclist_base
  WHERE birthday IS NOT NULL
    AND cid IS NOT NULL
    AND age = 19
  PRIMARY KEY (cid, birthday, age);

The results of this query:

SELECT *
FROM cycling.cyclist_by_birthday_and_age19;

are:

 cid                                  | birthday   | age | country    | name
--------------------------------------+------------+-----+------------+---------------------
 410919ef-bd1b-4efa-8256-b0fd8ab67029 | 1999-01-04 |  19 | Uzbekistan | Iskandarbek SHODIEV
 1c526849-d3a2-42a3-bcf9-7903c80b3d16 | 1998-12-23 |  19 |  Australia |       Kanden GROVE

(2 rows)

The following materialized view cyclist_by_age_birthday_cid uses the base table cyclist_base_ext. The WHERE clause ensures that only rows whose age, birthday, and cid columns are non-NULL are added to the materialized view.

CREATE MATERIALIZED VIEW IF NOT EXISTS cycling.cyclist_by_age_birthday_cid AS
  SELECT age, cid, birthday, country, name
  FROM cycling.cyclist_base_ext
  WHERE age IS NOT NULL
    AND birthday IS NOT NULL
    AND cid IS NOT NULL
  PRIMARY KEY (age, birthday, cid);

The results of this query:

SELECT *
FROM cycling.cyclist_by_age_birthday_cid
WHERE age = 19;

are:

 cid                                  | birthday   | age | country    | name
--------------------------------------+------------+-----+------------+---------------------
 410919ef-bd1b-4efa-8256-b0fd8ab67029 | 1999-01-04 |  19 | Uzbekistan | Iskandarbek SHODIEV
 1c526849-d3a2-42a3-bcf9-7903c80b3d16 | 1998-12-23 |  19 |  Australia |       Kanden GROVE

(2 rows)

The results of this query using a WHERE clause for two values:

SELECT *
FROM cycling.cyclist_by_age_birthday_cid
WHERE age = 19
  AND birthday = '1998-12-23';

are:

 age | birthday   | cid                                  | country   | name
-----+------------+--------------------------------------+-----------+---------------
  19 | 1998-12-23 | 1c526849-d3a2-42a3-bcf9-7903c80b3d16 | Australia | Kanden GROVES

(1 rows)

Notice that clustering columns must still be included in order. This query violates the rule:

SELECT *
FROM cycling.cyclist_by_age_birthday_cid
WHERE birthday = '1998-12-23';

Result:

materialized-view-cyclist-by-age.cql:195:InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot 
execute this query as it might involve data filtering and thus may have unpredictable performance. If you 
want to execute this query despite the performance unpredictability, use ALLOW FILTERING.

Using a materialized view to perform queries that are not possible on a base table

The following scenario shows how to use a materialized view to perform queries that are not possible on a base table unless ALLOW FILTERING is used. ALLOW FILTERING is not recommended because of the performance degradation. This table stores the cycling team mechanic information:

CREATE TABLE IF NOT EXISTS cycling.mechanic (
  emp_id int,
  dept_id int,
  name text,
  age int,
  birthdate date,
  PRIMARY KEY (emp_id, dept_id)
);

The table contains these rows:

 emp_id | dept_id | age | birthdate  | name
--------+---------+-----+------------+------------
      5 |       3 |  25 | 1996-10-04 | Lisa SMITH
      1 |       1 |  21 | 1992-06-18 | Fred GREEN
      2 |       1 |  22 | 1993-01-15 | John SMITH
      4 |       2 |  24 | 1995-08-19 | Jack JONES
      3 |       2 |  23 | 1994-02-07 |   Jane DOE

(5 rows)

This materialized view selects the columns from the previous table and contains a different primary key from the table:

CREATE MATERIALIZED VIEW IF NOT EXISTS cycling.mechanic_view AS
  SELECT emp_id, dept_id, name, age, birthdate
  FROM cycling.mechanic
  WHERE emp_id IS NOT NULL
    AND dept_id IS NOT NULL
    AND name IS NOT NULL
    AND age IS NOT NULL
    AND birthdate IS NOT NULL
  PRIMARY KEY (age, emp_id, dept_id);

This query retrieves the rows where the age is 21:

SELECT *
FROM cycling.mechanic_view
WHERE age = 21;

The previous query cannot be run on the base table without ALLOW FILTERING. The output from the previous query is as follows:

 age | emp_id | dept_id | birthdate  | name
-----+--------+---------+------------+------------
  21 |      1 |       1 | 1992-06-18 | Fred GREEN

(1 rows)

-

CREATE KEYSPACE CREATE ROLE

General Inquiries: +1 (650) 389-6000 info@datastax.com

© DataStax | Privacy policy | Terms of use

DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.

Kubernetes is the registered trademark of the Linux Foundation.

landing_page landingpage