如何在postgresql中找到具有特定列的表 [英] How to find a table having a specific column in postgresql

查看:216
本文介绍了如何在postgresql中找到具有特定列的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用postgresql 9.1。我有一个表的列名。是否可以找到有/有此列的表?怎么样?提前致谢。

I'm using postgresql 9.1. I have the column name of a table. Is it possible to find the table(s) that has/have this column? How? Thanks in advance.

推荐答案

您可以查询系统目录

select c.relname
from pg_class as c
    inner join pg_attribute as a on a.attrelid = c.oid
where a.attname = <column name> and c.relkind = 'r'

sql fiddle demo

这篇关于如何在postgresql中找到具有特定列的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆