Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use the INSERT statement to set custom Time to Live (TTL) values for new rows

Focus mode
Use the INSERT statement to set custom Time to Live (TTL) values for new rows - Amazon Keyspaces (for Apache Cassandra)
Note

Before you can set custom TTL values for rows using the INSERT statement, you must first enable custom TTL on the table. For more information, see Update table with custom Time to Live (TTL).

To overwrite a table's default TTL value by setting expiration dates for individual rows, you can use the INSERT statement:

  • INSERT – Insert a new row of data with a TTL value set.

Setting TTL values for new rows using the INSERT statement takes precedence over the default TTL setting of the table.

The following CQL statement inserts a row of data into the table and changes the default TTL setting to 259,200 seconds (which is equivalent to 3 days).

INSERT INTO my_table (userid, time, subject, body, user) VALUES (B79CB3BA-745E-5D9A-8903-4A02327A7E09, 96a29100-5e25-11ec-90d7-b5d91eceda0a, 'Message', 'Hello','205.212.123.123') USING TTL 259200;

To confirm the TTL settings for the inserted row, use the following statement.

SELECT TTL (subject) from my_table;
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.