pg 解析select语句的返回值

  1. 通过pg_typeof
//基础示例
SELECT pg_typeof(id) FROM t_basic_config LIMIT 1;

//多表join
SELECT pg_typeof(a.id),pg_typeof(b.user_password) FROM t_basic_config a
left join t_basic_admin b
on a.id=b.id LIMIT 1;
  1. 通过explain解析查询的所有字段和表,然后再去字段表里查询对应的定义
//解析select
EXPLAIN (VERBOSE, FORMAT JSON)
SELECT *
FROM t_basic_config a
left join t_basic_admin b
on a.id=b.id

//查询字段类型

SELECT
  column_name,
  data_type
FROM
  information_schema.columns
WHERE
  table_name = 't_basic_config';
posted @ 2025-09-10 21:14  Hey,Coder!  阅读(6)  评论(0)    收藏  举报