INSERT
General Syntax of INSERT
You can insert a record in a table by passing the values for each column of that table for that record.
The general syntax of a basic ZCQL data insertion operation is as follows:
copyINSERT INTO {BASE_TABLE_NAME} VALUES (VALUE1, VALUE2,..)
You must pass the values in the same order as the columns are present in the table.
Note:
- Ensure that you provide the right value for a column that matches the column’s data type.
- For columns where the IsUnique constraint is enabled, ensure that you don’t enter values that are already present in other records. Similarly, for the columns where the IsMandatory validator is enabled, ensure that you do not leave the data value blank.
- For a column where the data type is a Foreign Key, you must provide the ROWID of the parent table’s record which it refers, as its value.
Example:
To insert a record in the Movies table, execute the following query:
copyINSERT INTO Movies VALUES (2060,'Mission: Impossible – Fallout', '2018-7-27', '16:00:00', 053)
Note: If the values to be inserted are String values, you must pass the values enclosed in single quotations as shown above.
Partial Insert
You can also pass values only for specific columns in a table by specifying the column names which the values need to be inserted for. The syntax for a partial insert is as follows:
copyINSERT INTO {BASE_TABLE_NAME} (COLUMN_NAME1, COLUMN_NAME2,..) VALUES (VALUE1, VALUE2,..)
To insert a record and pass values for the MovieID and TheaterID columns alone in the Movies table, execute the following query:
copyINSERT INTO Movies (MovieID, TheaterID) VALUES (2061, 052)
Last Updated 2023-08-28 18:12:09 +0530 +0530
Yes
No
Send your feedback to us
Skip
Submit