postgresql中查询COMMENT注释的语句
tb_car表中DDL语句中有COMMENT
COMMENT ON COLUMN public.tb_car.car_id IS '主键'; COMMENT ON COLUMN public.tb_car.car_index_code IS '车辆编码'; COMMENT ON COLUMN public.tb_car.plate_no IS '车牌号码';
用如下语句查询
SELECT col.table_name, col.column_name, col.ordinal_position AS o, d.description FROM information_schema.columns col JOIN pg_class c ON c.relname = col.table_name LEFT JOIN pg_description d ON d.objoid = c.oid AND d.objsubid = col.ordinal_position WHERE col.table_schema = 'public' and col.table_name = 'tb_car'