SELECT DISTINCT CAMPOS.RDB$FIELD_NAME AS COLUMN_NAME,
CASE
WHEN DADOSCAMPO.RDB$FIELD_PRECISION > 0 THEN 'NUMERIC'
WHEN TIPOS.RDB$TYPE_NAME = 'LONG' THEN 'INTEGER'
WHEN TIPOS.RDB$TYPE_NAME = 'SHORT' THEN 'SMALLINT'
WHEN TIPOS.RDB$TYPE_NAME = 'INT64' THEN 'NUMERIC'
WHEN TIPOS.RDB$TYPE_NAME = 'VARYING' THEN 'VARCHAR'
WHEN TIPOS.RDB$TYPE_NAME = 'TEXT' THEN 'CHAR'
WHEN TIPOS.RDB$TYPE_NAME = 'BLOB' THEN 'BLOB SUB_TYPE'
ELSE TIPOS.RDB$TYPE_NAME
END AS FIELD_TYPE,
CASE
WHEN DADOSCAMPO.RDB$FIELD_TYPE IN(16,8) THEN DADOSCAMPO.RDB$FIELD_PRECISION
ELSE DADOSCAMPO.RDB$FIELD_LENGTH
END AS DATA_LENGTH, DADOSCAMPO.RDB$FIELD_SCALE AS DATA_SCALE,
CASE CAMPOS.RDB$NULL_FLAG WHEN 1 THEN 'N' ELSE 'Y' END AS NULLABLE
FROM
RDB$RELATIONS TABELAS, RDB$RELATION_FIELDS CAMPOS, RDB$FIELDS
DADOSCAMPO, RDB$TYPES TIPOS
WHERE TABELAS.RDB$RELATION_NAME = 'PESSOAS'
AND TIPOS.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
AND TABELAS.RDB$RELATION_NAME = CAMPOS.RDB$RELATION_NAME
AND CAMPOS.RDB$FIELD_SOURCE = DADOSCAMPO.RDB$FIELD_NAME
AND DADOSCAMPO.RDB$FIELD_TYPE = TIPOS.RDB$TYPE
ORDER BY CAMPOS.RDB$FIELD_POSITION
|