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'

posted @ 2024-04-10 18:08  木头左  阅读(264)  评论(0编辑  收藏  举报