1.查询所有数据库

SELECT DATNAME FROM sys_database

2.查询所有模式(名字空间)

SELECT NSPNAME FROM sys_namespace

3.查询所有表名

//查询所有表SELECT RELNAME FROM sys_class WHERE RELKIND='r'//查询某个模式下的所有表SELECT A.RELNAME FROM sys_class A,sys_namespace B WHERE A.RELNAMESPACE = B.OID AND A.RELKIND='r' AND B.NSPNAME='模式名'

4.查询某个表的表元数据

SELECT A.COLUMN_NAME as 字段名, A.TYPE_NAME as 字段类型, A.COLUMN_SIZE as 字段长度, A.DECIMAL_DIGITS as 小数位数, CAST((CASE WHEN A.NULLABLE=0 THEN 1 ELSE 2 END) as VARCHAR(500)) as 是否非空, --1:是 2:否 A.COLUMN_DEF as 默认值, DECODE((SELECT COLUMN_NAME FROM v_sys_primary_keys B WHEREA.TABLE_SCHEM=B.TABLE_SCHEM AND A.TABLE_NAME=B.TABLE_NAME), A.COLUMN_NAME, 1, 2) as 是否主键, --1:是 2:否 A.REMARKS as 注释 FROM v_sys_columns A WHERE A.TABLE_SCHEM='模式名' AND A.TABLE_NAME='表名' AND A.ORDINAL_POSITION>=0