【gp】取schema下表及其注释,去除分区表

【sql】

select a.tablename as tname

           b.remark      as remark

from

(

      select table_name tablename

      from information_schem.tables

      where upper(table_schema)=upper('your schema')

)    a

inner join 

(  

     select * from

     (

           select cls.relname as tablename,

                      cast(obj_description(cls.oid,'pg_class') as varchar) as remark

           from   pg_class cls

           left join pa_namespace nspc

           on cls.relnamespace=nspc.oid

           where upper(nspc.nspname)=upper('your schema')  and

                      cls.relchecks='0' and

                      cls.relkind='r'

       ) c

      where (c.tablename like '%your keyword%'  or c.remark like '%your keyword%'

) b

on a.tablename=b.tablename

order by a.tablename

【参数说明】

your schema:schema名称

your keyword:查询关键字

【注意】

以上代码经过手录而成,其中难免有误,请各位有实际环境的先验证一下。

END

posted @ 2022-08-20 09:00  不朽的飞翔  阅读(249)  评论(0编辑  收藏  举报