Some useful DB2 Queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Foreign Key Of Table*/ | |
SELECT | |
A.TBNAME, | |
REFTBNAME, | |
COLNAME | |
FROM SYSIBM.SYSRELS A, | |
SYSIBM.SYSFOREIGNKEYS B | |
WHERE A.RELNAME = B.RELNAME | |
AND A.TBNAME = B.TBNAME | |
AND A.TBNAME='Table_Name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Primary Key of Table*/ | |
SELECT A.COLNAME, | |
B.TBNAME | |
FROM SYSIBM.SYSKEYS A, | |
SYSIBM.SYSINDEXES B | |
WHERE B.NAME = A.IXNAME | |
AND B.TBNAME='Table_Name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Schema Of Stored Procedure*/ | |
SELECT * | |
FROM SYSIBM.SYSROUTINEAUTH | |
WHERE | |
specificname LIKE 'SP_Name' | |
AND grantee NOT IN ('@B00120','@C00120') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Find all stored procedure using a table*/ | |
SELECT | |
GRANTOR, | |
GRANTEE, | |
SELECTAUTH, | |
INSERTAUTH, | |
UPDATEAUTH, | |
DELETEAUTH | |
FROM SYSIBM.SYSTABAUTH | |
WHERE | |
GRANTEE LIKE 'SP_Prefix%' | |
AND TTNAME LIKE '%table_name%' | |
AND GRANTOR IN ('table_schema') | |
ORDER BY GRANTEE ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Schema Of Stored Procedure*/ | |
SELECT | |
CREATOR | |
FROM SYSIBM.SYSVIEWS | |
WHERE NAME='Table_Name' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment