postgre 常用語法,如 group_concat用法


1.查詢postgre的表所有字段列

select table_name, column_name from information_schema.columns
where table_schema='public' and table_name='t_user';

2.將上面的列,group_concat拼接

select string_agg(column_name,',') 
from information_schema.columns
where table_schema='public' and table_name='t_user';

 拼表的自字段查詢

select 'select '
||( select string_agg(column_name,',') from information_schema.columns where table_schema='public' and table_name='t_user' ) ||' from t_user';

----------------
select id,name,cnname,password from t_user

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM