Subject Re: How can I get field constraints like Oracle All_Constraints view ...
Author cicerobillo
OK. Thanks a lot.

See result below:


CREATE VIEW CHECK_CONSTRAINTS
(
CONSTRAINT_NAME,
CHECK_CLAUSE
)
AS
SELECT RDB$CONSTRAINT_NAME, RDB$TRIGGER_SOURCE
FROM RDB$CHECK_CONSTRAINTS RC, RDB$TRIGGERS RT
WHERE RT.RDB$TRIGGER_NAME = RC.RDB$TRIGGER_NAME;


-----------------------------------------------------

CREATE VIEW CONSTRAINTS_COLUMN_USAGE
(
TABLE_NAME,
COLUMN_NAME,
CONSTRAINT_NAME
)
AS
SELECT RDB$RELATION_NAME, RDB$FIELD_NAME, RDB$CONSTRAINT_NAME
FROM RDB$RELATION_CONSTRAINTS RC, RDB$INDEX_SEGMENTS RI
WHERE RI.RDB$INDEX_NAME = RC.RDB$INDEX_NAME;

-----------------------------------------------------

CREATE VIEW REFERENTIAL_CONSTRAINTS
(
CONSTRAINT_NAME,
UNIQUE_CONSTRAINT_NAME,
MATCH_OPTION,
UPDATE_RULE,
DELETE_RULE
)
AS
SELECT RDB$CONSTRAINT_NAME, RDB$CONST_NAME_UQ, RDB$MATCH_OPTION,
RDB$UPDATE_RULE, RDB$DELETE_RULE
FROM RDB$REF_CONSTRAINTS;

-----------------------------------------------------

CREATE VIEW TABLE_CONSTRAINTS
(
CONSTRAINT_NAME,
TABLE_NAME,
CONSTRAINT_TYPE,
IS_DEFERRABLE,
INITIALLY_DEFERRED
)
AS
SELECT RDB$CONSTRAINT_NAME, RDB$RELATION_NAME,
RDB$CONSTRAINT_TYPE, RDB$DEFERRABLE,
RDB$INITIALLY_DEFERRED
FROM RDB$RELATION_CONSTRAINTS;

-----------------------------------------------------

SELECT rt.*, rc.*, T.rdb$type_name
FROM RDB$CHECK_CONSTRAINTS RC, RDB$TRIGGERS RT, rdb$types T
WHERE RT.RDB$TRIGGER_NAME = RC.RDB$TRIGGER_NAME
AND RT.rdb$trigger_type = T.rdb$type
AND T.rdb$type_name = 'CHECK_CONSTRAINT';




--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
>
>
>
> > This is ok, but what about Check Constraints?
>
> Download yourself the InterBase 6 Language Reference
> and check the chapter "System tables and views".
>
> With regards,
>
> Martijn Tonies
> Database Workbench - tool for InterBase, Firebird, MySQL, Oracle &
MS SQL
> Server
> Upscene Productions
> http://www.upscene.com
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com