Insert and update data
Data can be inserted or updated into tables. Many different types of data can be stored in CQL tables.
Inserting and updating data in CQL are the same operation. Data can be upserted, meaning that the previously stored data is deleted and replaced with the updated data.
- Insert simple data
-
Inserting set data with the INSERT command.
- Collection - Set
-
Insert or update data into a set column.
- Collection - List
-
Insert or update data into a list column.
- Collection - Map
-
Insert or update data into a map column.
- Tuple
-
Insert or update data into a tuple column.
- User-defined type (UDT)
-
Insert or update data into a user-defined type column.
- UUID and timeUUID
-
Insert data into a UUID or time UUID column.
- Date
-
Insert data into a date column.
- Time
-
Insert data into a time column.
- Timestamp
-
Insert data into a timestamp column.
- Duration
-
Insert data into a duration column.
- Counter
-
Update data in a counter column.
- Static columns
-
Insert data into a static column.
- Lightweight transactions (LWTs)
-
INSERT and UPDATE statements that use the IF clause support lightweight transactions, also known as Compare and Set (CAS).
- Batch inserts and updates
-
Perform multiple writes in the same command.
- JSON-formatted values
-
Inserting JSON data with the INSERT command for testing queries. Starting with DataStax Enterprise 5.0, JSON data can be inserted.
- Importing data from a CSV file
-
Inserting data with the cqlsh command COPY from a CSV file is common for testing queries.
- Deleting values from a column or entire row
-
Use the DELETE statement to replace the value in a column with null or to remove an entire row of data.
- Expiring data with time-to-live
-
Use time-to-live (TTL) to expire data in a column or table.