一、GP或PgSQL
-- 获取表结构
SELECT a.schemaname schema_name, a.tablename table_name, string_agg(DISTINCT b.column_name, ',') AS columns FROM (SELECT schemaname, tablename FROM pg_tables WHERE schemaname = 'public') a
LEFT JOIN (SELECT table_name, column_name FROM information_schema.columns where table_schema = 'public') b
ON a.tablename = b.table_name
GROUP BY a.schemaname, a.tablename;
文章来源地址https://www.toymoban.com/news/detail-741388.html
文章来源:https://www.toymoban.com/news/detail-741388.html
到了这里,关于数据库——获取表结构SQL的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!