table-mechanic

INSERT INTO cycling.mechanic (
  emp_id, dept_id, name, age, birthdate
) VALUES (
  1, 1, 'Fred GREEN', 21, '1992-06-18'
);

INSERT INTO cycling.mechanic (
  emp_id, dept_id, name, age, birthdate
) VALUES (
  2, 1, 'John SMITH', 22, '1993-01-15'
);

INSERT INTO cycling.mechanic (
  emp_id, dept_id, name, age, birthdate
) VALUES (
  3, 2, 'Jane DOE', 23, '1994-02-07'
);

INSERT INTO cycling.mechanic (
  emp_id, dept_id, name, age, birthdate
) VALUES (
  4, 2, 'Jack JONES', 24, '1995-08-19'
);

INSERT INTO cycling.mechanic (
  emp_id, dept_id, name, age, birthdate
) VALUES (
  5, 3, 'Lisa SMITH', 25, '1996-10-04'
);
DESCRIBE MATERIALIZED VIEW cycling.mechanic_view;
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);
DROP MATERIALIZED VIEW IF EXISTS cycling.mechanic_view;
SELECT * FROM cycling.mechanic;
SELECT * FROM cycling.mechanic_view WHERE age = 21;
SELECT (emp_id + dept_id) / age FROM cycling.mechanic;
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)
);
DESCRIBE TABLE cycling.mechanic;
DROP TABLE IF EXISTS cycling.mechanic;

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

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.

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