vlambda博客
学习文章列表

mysql 查询库中所有的字段,逗号分隔

-- 查询mysql所有表及字段,字段逗号分隔

select table_name, concat('select ', group_concat(column_name order by ordinal_position SEPARATOR ','), ' from ', table_name) AS t_info   from information_schema.COLUMNS where table_schema = 'schema' group by table_name

--查询pg所有表及字段,字段逗号分隔

select table_name, concat('select ', string_agg(column_name, ',' order by ordinal_position), ' from ', table_name) from information_schema.columns where table_schema='schema' group by table_name