- DELETE FROM TABLE
- INSERT INTO TABLE
- TRUNCATE TABLE
DELETE FROM TABLE
Removes rows from the specified table. You can use theWHERE clause to specify the rows to remove. If a DELETE SQL statement lacks the WHERE clause, then the database deletes all rows in the table.
To use this statement, you must have the DELETE privilege for the table.
For details and examples, see Remove Records from an Ocient System.
DELETE actions cannot be undone.If a DELETE operation fails during execution, the database rolls back the changes and returns to its original state.Due to limitations of the JDBC API, the reported modified row count might not be accurate for
DELETE operations that are larger than two billion rows.SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table, specified as a string, indicates where to delete rows. |
cte | string | A common table expression that defines temporary data for the DELETE statement. For details about using common table expressions, see WITH. |
<filter_clause> | None | A logical combination of predicates that filter the rows to delete based on one or more columns. For details, see the WHERE clause. The DELETE SQL statement removes all rows from a table if you do not include the WHERE clause. |
DELETE SQL statement removes all rows in the movies table that have a budget of less than 10000.
SQL
WITH keyword to find rows representing all transactions that occurred before 2022 that are less than $100. The DELETE SQL statement receives the results from the common table expression. Then, the database executes this statement to delete the corresponding rows.
SQL
INSERT INTO TABLE
INSERT INTO inserts rows into a table in the current database using literal values, column references, function executions, computed expressions, or column default values.
This SQL statement requires the INSERT privilege for the relevant table.
Due to limitations of the JDBC API, the reported modified row count might not be accurate for insert operations that are larger than two billion rows.
SQL
Using
DEFAULT VALUES inserts a single row where each target column is populated with its column defaults (as defined in the column definition) instead of an explicit VALUES list.For table columns that do not each have a defined default value, the inserted row is NULL. If the column has no default and also has the NOT NULL constraint, the insert operation generates an error.| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table for insertion. |
col1, col2 [, ... ] | string | A list of specific columns to insert specific values. This column list defaults to all columns in the table if you do not specify any column names. The INSERT statement can use a subset of the table columns. Any columns not included in the statement are populated with their column default value in their column definition. If the column definition does not specify a default, the inserted row is NULL. If the column has no default and also has the NOT NULL constraint, the insert operation generates an error. |
cte | string | A common table expression that defines temporary data for the INSERT statement. For details about using common table expressions, see WITH. |
query | string | A SELECT query that defines values or a table and any of its columns that should be inserted into the specified table_name. |
row1_exp1, row1_exp2 [, ...] | string | The expressions to insert into columns in the table. This list must match the number of columns specified in the INSERT statement. Similarly, each expression must match the data type of the column that corresponds to its position. Expressions can be any of the following: L****iterals: 1, 3.14, ‘abc’, DATE '2024-01-01', etc.Column references: If your INSERT statement includes a common table expression using a WITH clause, you can reference columns from the separate table in that clause.Function executions: ABS(-5), NOW(), ST_DISTANCE, etc.Computed expressions: price * quantity, COALESCE(x, 0), etc.Column default values: Use the keyword DEFAULT to insert a default value specified in the column definition. If the column definition does not specify a default, the inserted row is NULL. If the column has no default and also has the NOT NULL constraint, the insert operation generates an error. |
system.table_b into system.table_a.
SQL
system.table_b.id_col_b into system.table_a.id_col_a and system.table_b.int_col_b into system.table_a.int_col_a.
SQL
product— Product identifierquantity— Quantity of the product soldsale_date— Date of sale
SQL
SQL
sales table before inserting rows into the monthly_sales_summary table.
The example uses the monthly_sales_summary table created by this CREATE TABLE statement with these non-nullable columns:
product_id— Product identifiermonth— Month part of the datetotal_quantity— Total quantity of the product
SQL
WITH keyword extracts the month from the sale date sale_date and calculates the sum of the quantity sold total_quantity of the product from the sales table before inserting this data. Then, the INSERT SQL statement specifies to insert the data into the monthly_sales_summary table.
SQL
customers table with these columns:
customer_id— Customer identifiername— Customer namestatus— Customer status with the defaultactivestatuscreated_at— Created date
SQL
DEFAULT VALUES keyword to insert one row of default values into the table. For columns that lack a defined default value, the operation inserts a NULL row.
SQL
status column, which has the active default value.
SQL
SQL
DEFAULT keyword as one of the row values in the INSERT statement.
SQL
SQL
INSERT INTO TABLE USING LOADERS
Specify one or more Loader Nodes for executing theINSERT INTO SQL statement. If you do not use this option, the Ocient System uses all Loader Nodes that are live to execute the SQL statement.
This statement is useful for managing loading operations, particularly when balancing multiple loads of different sizes and resource requirements. Alternatively, this statement can also help simplify small batch loads by sourcing the data from a single Loader Node.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
streamloader | string | A unique name for the Loader Node. Identify the names of Loader Nodes from the sys.nodes table by using this query: SELECT name FROM sys.nodes;If the name of the streamloader contains special characters, you must enclose it in quotes, such as "stream-loader1". |
For the query to execute successfully, the specified names must:
- Identify nodes that are live.
- Identify nodes that have the Loader role.
system.table_b.id_col_b into system.table_a.id_col_a and system.table_b.int_col_b into system.table_a.int_col_a. Use the Loader Node named stream-loader1 to execute this SQL statement.
SQL
stream-loader2 and stream-loader3.
SQL
TRUNCATE TABLE
TRUNCATE TABLE removes some or all records from an existing table in the current database. The system deletes the truncated data, but the table and its schema remain intact in the system even if all data is deleted. If the entire table is truncated, Global Dictionary Compression tables remain in place.
To truncate a table, you must have the DELETE privilege for the table.
To remove a subset of rows from a table, you can use the DELETE FROM TABLE SQL statement.
For details and examples of using TRUNCATE, see Remove Records from an Ocient System.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to truncate. |
segment_group_id | numeric | Identifier of the segment group. |
students.
SQL
us.students.
SQL
students.
SQL
us.students.
SQL

