# 查询主键: SELECT K.COLNAME AS 主键名 FROM SYSCAT.KEYCOLUES K WHERE TABSCHEMA='SCHEMA' AND TABNAME='TABNAME'; # 查询索引 SELECT I.INDNAME AS 索引名,I.COLNAMES AS 索引字段 FROM SYSCAT.INDEXS I WHERE TABSCHEMA='SCHEMA' AND TABNAME='TABNAME'; # 查询所有的表 SELECT T.NAME AS 表英文名,T.REMARKS AS 表中文,T.TYPE AS 表类型 FROM SYSIBM.SYSTABLES T WHERE CREATOR='SCHEMA'; # 查询表字段 SELECT * FROM SYSCAT.COLUMNS WHERE TABNAME='TABNAME'; SELECT C.COLNAME AS 字段英文名,C.REMARKS AS 字段中文注释,C.TYPENAME AS 字段类型,C.LENGTH AS 字段长度,C.NULLS AS 是否允许为空 FROM SYSCAT.COLUMNS C WHERE TABNAME='TABNAME' # 查询存储过程 SELECT P.PROCNAME AS 存储过程名,P.SPECIFICNAME AS 存储过程别名 FROM SYSCAT.PROCEDURES P WHERE PROCSCHEMA='SCHEMA_NAME' # 查询表约束 SELECT INDSCHEMA,INDNAME AS 约束名,COLNAMES AS 约束字段名,UNIQUERULE AS 约束状态 FROM SYSCAT.INDEXS WHERE TABSCHEMA='SCHEMA_NAME' AND TABNAME='TABNAME' AND UNIQUERULE IN ('U','P');