<<<<<<< HEAD disk_space_used | H2 | SQLDoc
Skip to main content

disk_space_used

1. DISK_SPACE_USED Function

======= disk_space_used | H2 Function | SQLDoc

disk_space_used

1. DISK_SPACE_USED Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The DISK_SPACE_USED function in H2 database is used to retrieve the total disk space used by a specific table or all tables in a schema.

2. Syntax

The syntax for the DISK_SPACE_USED function in H2 database is as follows:

DISK_SPACE_USED([schemaName.]tableName)

Arguments

  • schemaName (optional): The name of the schema where the table is located. If not specified, the current schema is used.
  • tableName: The name of the table for which you want to retrieve the disk space usage. If not specified, the disk space usage for all tables in the specified schema will be returned.

Return

  • The DISK_SPACE_USED function returns the total disk space used by the specified table(s) in bytes.

3. Notes

  • The DISK_SPACE_USED function only works with regular tables, and not with temporary tables or views.
  • If the specified table or schema does not exist, the function will return NULL.
  • The disk space usage includes the size of the table data, indexes, and any associated objects.

4. Examples

Here are a few examples demonstrating the usage of the DISK_SPACE_USED function in H2 database:

Example 1 - Retrieving disk space usage for a specific table:

SELECT DISK_SPACE_USED('public.myTable') AS space_used;

Output:

space_used
-----------
123456789

Example 2 - Retrieving disk space usage for all tables in a schema:

SELECT TABLE_NAME, DISK_SPACE_USED(TABLE_SCHEMA || '.' || TABLE_NAME) AS space_used
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'public';

Output:

TABLE_NAME | space_used
-----------+-----------
table1 | 1000000
table2 | 2000000
table3 | 1500000
  • DISK_SPACE_FREE - Calculate free disk space
  • DISK_SPACE_USED_PERCENT - Calculate disk space usage percentage