Skip to main content
Detach a tablespace from one or more s. This only means that new s are not placed on the detached tablespace. This is useful, for instance, when a tablespace is running low on disk space and one would like to prevent new s from being created in the tablespace. The detached tablespace itself and any existing s with data on it remains unchanged and continue to work as before, including being available for queries. Note that newly inserted data rows may still be inserted into an existing on the detached tablespace since existing data is not cleared from a detached tablespace. A detached tablespace can be reattached if desired to once again be considered for placement.

Samples

Detach the tablespace disk1 from the conditions:
SELECT detach_tablespace('disk1', 'conditions');
SELECT detach_tablespace('disk2', 'conditions', if_attached => true);
Detach the tablespace disk1 from all s that the current user has permissions for:
SELECT detach_tablespace('disk1');

Arguments

NameTypeDefaultRequiredDescription
tablespaceTEXT-Tablespace to detach.
hypertableREGCLASS-Hypertable to detach a the tablespace from.
if_attachedBOOLEANFALSESet to true to avoid throwing an error if the tablespace is not attached to the given table. A notice is issued instead.
When giving only the tablespace name as argument, the given tablespace is detached from all s that the current role has the appropriate permissions for. Therefore, without proper permissions, the tablespace may still receive new s after this command is issued. When specifying a specific , the tablespace is only detached from the given and thus may remain attached to other s.