Sqlite3查询数据库的总表数:
select name from sqlite_master where type='table' order by name
获取某张表的所有字段信息:
PRAGMA table_info("TableName")
TableName为待查询表名
查询一张表有多少条数据
select count(*) from TableName
Postgresql对数据表查询指令:
查询指定表的字段名及类型:
select
a.attname as fieldName,
concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as fieldType
from pg_class c, pg_attribute a , pg_type t
where c.relname = 'TableName'
and a.attnum>0
and a.attrelid = c.oid
and a.atttypid = t.oid
ORDER BY c.relname DESC,a.attnum ASC
结果只保留两列,列名分别为fieldName, fieldType
TableName为待查询的表名
最近工作用到,记录下来以备后续方便查找。