mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 14:26:00 +00:00
feat: firebird FKs, PKs, procedures, funcs
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
module.exports = `
|
||||
SELECT
|
||||
TRIM(rel.RDB$OWNER_NAME) AS "schemaName",
|
||||
TRIM(rc.RDB$RELATION_NAME) AS "pureName",
|
||||
TRIM(rc.RDB$CONSTRAINT_NAME) AS "constraintName",
|
||||
TRIM(iseg.RDB$FIELD_NAME) AS "columnName",
|
||||
CAST(NULL AS VARCHAR(63)) AS "refColumnName",
|
||||
FALSE AS "isIncludedColumn",
|
||||
CASE COALESCE(idx.RDB$INDEX_TYPE, 0) -- Treat NULL as 0 (ascending)
|
||||
WHEN 1 THEN TRUE -- Assuming 1 means DESCENDING for regular (non-expression) indexes
|
||||
ELSE FALSE -- Assuming 0 (or NULL) means ASCENDING for regular indexes
|
||||
END AS "isDescending"
|
||||
FROM
|
||||
RDB$RELATION_CONSTRAINTS rc
|
||||
JOIN
|
||||
RDB$RELATIONS rel ON rc.RDB$RELATION_NAME = rel.RDB$RELATION_NAME
|
||||
JOIN
|
||||
RDB$INDICES idx ON rc.RDB$INDEX_NAME = idx.RDB$INDEX_NAME
|
||||
JOIN
|
||||
RDB$INDEX_SEGMENTS iseg ON idx.RDB$INDEX_NAME = iseg.RDB$INDEX_NAME
|
||||
WHERE
|
||||
rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
|
||||
AND COALESCE(rel.RDB$SYSTEM_FLAG, 0) = 0 -- Typically, you only want user-defined tables
|
||||
ORDER BY
|
||||
"schemaName",
|
||||
"pureName",
|
||||
"constraintName",
|
||||
iseg.RDB$FIELD_POSITION;
|
||||
`;
|
||||
Reference in New Issue
Block a user