Firebird SQL: Check if notNULL constraint is set for a specific column?
I want my C# program to know if the notNULL constraint is set for a specific Firebird database column. Can it be checked dynamically, perhaps by querying the meta data? I find the Firebird documentation to be very sparse.
Also, how does Firebird provide information what columns exist in a specific 开发者_JAVA技巧table?
To do it manually, use the following statement:
select rdb$null_flag
from rdb$relation_fields
where rdb$relation_name = 'MyTable' and rdb$field_name = 'MyField'
Alternatively you may try exploring FbDataReader.GetSchemaTable()
.
You need to request the Firebird metadata for the constraints; all information describing them is stored in system tables. For an example on how to do that see the “List CONSTRAINTs” section on the following page: http://www.alberton.info/firebird_sql_meta_info.html.
精彩评论