ALTER
ALTER
can be used to modify any database options, table options or metadata of the table, including:
- Modify database options
- Add/Drop/Modify a column
- Set/Drop column default values
- Drop column default values
- Rename a table
- Modify table options
ALTER DATABASE
ALTER DATABASE
statements can be used to modify the options of databases.
Syntax
ALTER DATABASE db
[SET <option_name>=<option_value> [, ...]
| UNSET <option_name> [, ...]
]
Currently following options are supported:
ttl
: Specifies the default retention time for data in the database. Data exceeding this retention period will be deleted asynchronously.- If
ttl
was not previously set, defining a newttl
usingALTER
will result in the deletion of data that exceeds the specified retention time. - If
ttl
was already set, modifying it viaALTER
will enforce the updated retention time immediately, removing data that exceeds the new retention threshold. - If
ttl
was previously set and is unset usingALTER
, new data will no longer be deleted. However, data that was previously deleted due to the retention policy cannot be restored.
- If
Examples
Modify default retention time of data in database
Change the default retention time of data in the database to 1 day:
ALTER DATABASE db SET 'ttl'='1d';
Remove the default retention time of data in the database:
ALTER DATABASE db UNSET 'ttl';