INSERT INTO CUBE
INSERT INTO CUBE cube_name [WHERE condition]
Insert data into a star-tree cube. Predicate information is optional. If predicate provided, only data matching the given predicate are processed from the source table and inserted into the cube. Otherwise, entire data from the source table is processed and inserted into Cube.
Insert data based on condition into the
INSERT INTO CUBE orders_cube WHERE orderdate > date '1999-01-01'; INSERT INTO CUBE order_all_cube;
- Insert statement does not allow different columns to be used in the where clause for successive inserts.
CREATE CUBE orders_cube ON orders WITH (AGGREGATIONS = (count(*)), GROUP = (orderdate)); INSERT INTO CUBE orders_cube WHERE orderdate BETWEEN date '1999-01-01' AND date '1999-01-05'; -- This statement would fail because its possible the Cube already contain rows matching the given predicate. INSERT INTO CUBE orders_cube WHERE location = 'Canada';
Note: this means that columns used in the first insert must be used in every insert predicate following the first to avoid inserting duplicate data.