查看元数据信息

通过字段名称查找中文描述信息

postgre测试通过,gp不清楚

  1. select
  2. a.attnum,
  3. (
  4. select
  5. description
  6. from
  7. pg_catalog.pg_description
  8. where
  9. objoid = a.attrelid
  10. and objsubid = a.attnum) as descript ,
  11. a.attname,
  12. pg_catalog.format_type(a.atttypid,
  13. a.atttypmod) as data_type
  14. from
  15. pg_catalog.pg_attribute a
  16. where
  17. 1 = 1
  18. and a.attrelid =(
  19. select
  20. oid
  21. from
  22. pg_class
  23. where
  24. relname = 'room' ) --表名称
  25. and a.attnum>0
  26. and not a.attisdropped
  27. order by
  28. a.attnum;

GP通过字段名称查找中文描述信息

  1. SELECT
  2. 'tablename' AS TABLE_NAME,
  3. A .attname AS COLUMN_NAME,
  4. d.description AS description
  5. FROM
  6. pg_attribute A
  7. LEFT JOIN pg_index P ON P .indrelid = A .attrelid
  8. AND A .attnum = ANY (P .indkey)
  9. LEFT JOIN pg_description d ON d.objoid = A .attrelid
  10. AND d.objsubid = A .attnum
  11. LEFT JOIN pg_attrdef f ON f.adrelid = A .attrelid
  12. AND f.adnum = A .attnum
  13. WHERE
  14. A .attnum > 0
  15. AND NOT A .attisdropped
  16. AND A .attrelid = 'ods_mysql_work_order' :: regclass
  17. ORDER BY
  18. A .attnum;

创建测试数据

创建100万条测试数据

  1. select i,'text:'||i as text,i*10 as a into poc.test from generate_series(1,10) as i;
  2. insert into poc.test(i,a,text) SELECT generate_series(1,1000000) as key,(random()*100.)::numeric(4,2),repeat('1',(random()*25)::integer) ORDER BY random();