apple=# select * from (select a.relname, char_length(a.relname) as tb_name_length, b.attname, char_length(b.attname) as att_name_length, d.typname, b.attlen, b.attnum from pg_class a, pg_attribute b ,pg_tables c , pg_type d where b.attrelid = a.oid and b.attnum > 0  and c.schemaname = 'public' and a.relname = c.tablename and b.atttypid = d.oid ) as d where d.tb_name_length > 10 or att_name_length > 10;
        relname        | tb_name_length |      attname       | att_name_length |  typname  | attlen | attnum
-----------------------+----------------+--------------------+-----------------+-----------+--------+--------
 test_0001              |              8 | datatypename       |              12 | varchar   |     -1 |      2
 test_0001              |              8 | startuptime        |              11 | timestamp |      8 |      5

 

暂时这样写,后续修改从pg_namespace获取schema为public的表:

 

select * from (select a.relname, char_length(a.relname) as tb_name_length, b.attname, char_length(b.attname) as att_name_length, d.typname, b.attlen, b.attnum from pg_class a, pg_attribute b ,pg_namespace c , pg_type d where b.attrelid = a.oid and b.attnum > 0  and c.nspname = 'public' and a.relnamespace = c.oid and b.atttypid = d.oid ) as d where d.tb_name_length > 10 or att_name_length > 10;

 

相关文章:

  • 2021-08-21
  • 2022-03-07
  • 2022-01-13
  • 2021-11-18
  • 2022-12-23
  • 2021-12-12
  • 2022-01-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2021-08-27
  • 2021-10-02
  • 2021-10-13
相关资源
相似解决方案