Retorna tamanho de consumo do campo da tabela
SQL:
execute block returns (tamanho numeric(18), TABELA varchar(100), CAMPO varchar(100)) as
declare variable xsql varchar(8000);
begin
for select trim(rdb$field_name), trim(rdb$relation_name) from rdb$relation_fields into :campo, :tabela do
begin
:xsql = 'select sum(bit_length('||:campo||')) from '||:tabela;
execute statement :xsql into :tamanho;
if (:tamanho > 0 ) then
begin
suspend;
end
end
end
Retorno:
| TAMANHO | TABELA | CAMPO |
----------------------------------------------------------------------
| 192 | NOMETABELA | COLUNADATABELA |
| 256 | NOMETABELA | COLUNA2DATABELA |
| 8 | NOMETABELA2 | COLUNADATABELA2 |
| 160 | NOMETABELA3 | COLUNADATABELA3 |
| ... | ... | ... |