Subject | Column Types |
---|---|
Author | AngelBlaZe |
Post date | 2012-04-27T10:03:09Z |
I use the following query:
select
a.rdb$field_name as name,
coalesce(a.rdb$null_flag,0) as "isnotnull",
a.RDB$DEFAULT_SOURCE as dflt_value,
b.rdb$CHARACTER_LENGTH as "length",
b.rdb$field_scale as scale,
b.rdb$field_sub_type as subtype,
b.rdb$field_precision as "precision",
b.rdb$field_type as type,
iif(position('RDB$' in b.rdb$field_name) = 0,b.rdb$field_name,null) as "domain",
1 as pk,
a.RDB$FIELD_SOURCE as fsource,
a.rdb$description as description
from rdb$relation_fields a,
rdb$fields b where a.rdb$field_source = b.rdb$field_name
and a.rdb$relation_name = 'YOURTABLENAME' order by a.rdb$field_position asc
You then have to use that information to get to the definition.
for example
a decimal(10,5) column
would have using the query above:
type = 16 And subtype = 2
precision = 10
scale = 5
some common types:
typemap(8) = ddTypes.aInteger
typemap(37) = ddTypes.aString
typemap(7) = ddTypes.aSmallInt
typemap(16) = ddTypes.aDecimal
typemap(12) = ddTypes.aDate
typemap(35) = ddTypes.aDateTime
typemap(261) = ddTypes.aByte
I don't know if there is a reference for this, I just reverse engineered it from known columns.
Hope it helps.
select
a.rdb$field_name as name,
coalesce(a.rdb$null_flag,0) as "isnotnull",
a.RDB$DEFAULT_SOURCE as dflt_value,
b.rdb$CHARACTER_LENGTH as "length",
b.rdb$field_scale as scale,
b.rdb$field_sub_type as subtype,
b.rdb$field_precision as "precision",
b.rdb$field_type as type,
iif(position('RDB$' in b.rdb$field_name) = 0,b.rdb$field_name,null) as "domain",
1 as pk,
a.RDB$FIELD_SOURCE as fsource,
a.rdb$description as description
from rdb$relation_fields a,
rdb$fields b where a.rdb$field_source = b.rdb$field_name
and a.rdb$relation_name = 'YOURTABLENAME' order by a.rdb$field_position asc
You then have to use that information to get to the definition.
for example
a decimal(10,5) column
would have using the query above:
type = 16 And subtype = 2
precision = 10
scale = 5
some common types:
typemap(8) = ddTypes.aInteger
typemap(37) = ddTypes.aString
typemap(7) = ddTypes.aSmallInt
typemap(16) = ddTypes.aDecimal
typemap(12) = ddTypes.aDate
typemap(35) = ddTypes.aDateTime
typemap(261) = ddTypes.aByte
I don't know if there is a reference for this, I just reverse engineered it from known columns.
Hope it helps.
--- In firebird-support@yahoogroups.com, "Matteo Pasqualini" <pasqua91@...> wrote:
>
> hi iâm an IT student and iâve got problems about using System Tables to get information abiut my database. iâve got some questions and i canât find any answer.
> my questions are :
>
> - how can i get the field type of a specific field in the table?
> for example if i create a table with a field named âtestâ and type âDecimal (10,5)â how can i get âDecimal (10,5)â using System Tables?
>
> - how can i get the domain name that i create?
> for example if i create a domain named âYES_NOâ how can i get âYES_NOâ with System Tables?
>
> thanks in advance
>
>
>
> [Non-text portions of this message have been removed]
>