獲取資料庫中所有table名:
select tablename from pg_tables
where tablename not like 'pg%'
and tablename not like 'sql_%'
order by tablename;
獲取資料庫中所有table名及table的註解資訊:
select tablename,obj_description(relfilenode,'pg_class') from pg_tables a, pg_class b
where
a.tablename = b.relname
and a.tablename not like 'pg%'
and a.tablename not like 'sql_%'
order by a.tablename;
獲取指定table的所有字段資訊:
select col_description(a.attrelid,a.attnum) as comment,format_type(a.atttypid,a.atttypmod) as type,a.attname as name, a.attnotnull as notnull
from pg_class as c,pg_attribute as a
where c.relname = 'tablename' and a.attrelid = c.oid and a.attnum>0
查詢欄位名、字段型別及字段長度和字段注釋:
select a.attnum,a.attname,concat_ws('',t.typname,substring(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as type,d.description from pg_class c, pg_attribute a , pg_type t, pg_description d
where c.relname = 'table_name' and a.attnum>0 and a.attrelid = c.oid and a.atttypid = t.oid and d.objoid=a.attrelid and d.objsubid=a.attnum
獲取Redis所有的鍵值對
redis命令級別實現 scan cursor match pattern count count 1spring data redis實現 override public list getallredisval1 zset型別的鍵值獲取 if redistemplate.type key code...
如何查PostgreSQL 資料庫中所有的表
這個也是從 oid2name 中扒出來的 postgres localhost bin oid2name d postgres from database postgres now select pg catalog.pg relation filenode c.oid as filenode re...
如何查PostgreSQL 資料庫中所有的表
1 通過命令bai行查詢 d 資料庫 得到所有表du的名字 d 表名 得到表結構zhi 2 通過sql語句查詢 select from pg tables 得到當前db中所有dao表的資訊 這裡pg tables是系統檢視 select tablename from pg tables where ...