Tech Tip: How to check the size of a table using SQL
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: April 13, 2012
The SQL function BIT_LENGTH can be used to get the size of a field in bits. Using this function in combination with the SQL SUM function, the total size of a table can be found.
Below is an example of how the size of the data in Table_1 with three fields (Filed_1, Field_2, and Field_3) can be obtained in bits and then converted into mega bytes:
C_INTEGER($result_in_bits) C_REAL($result_in_mb;$byte_per_bits;$megabyte_per_bytes) $byte_per_bits:=1/8 $megabyte_per_bytes:=1/1048576 Begin SQL SELECT SUM (BIT_LENGTH (Field_1) + BIT_LENGTH (Field_2) + BIT_LENGTH (Field_3)) FROM Table_1 INTO :$result_in_bits End SQL $result_in_mb:=$result_in_bits*$byte_per_bits*$megabyte_per_bytes |