pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedis there a refactor
5+ messages / 4 participants
[nested] [flat]
* is there a refactor
@ 2011-04-05 14:27 John Fabiani <johnf@jfcomputer.com>
2011-04-05 14:39 ` Re: is there a refactor Viktor Bojović <viktor.bojovic@gmail.com>
2011-04-05 14:44 ` Re: is there a refactor Adrian Klaver <adrian.klaver@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: John Fabiani @ 2011-04-05 14:27 UTC (permalink / raw)
To: pgsql-sql
Hi,
I would like to have a simple way to retrieve information for a field name.
By that I mean have some SQL select that will return all the tables a field
name exist within a database. I did not find anything with google but of
course google depends on the search string.
Thanks in advance,
Johnf
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: is there a refactor
2011-04-05 14:27 is there a refactor John Fabiani <johnf@jfcomputer.com>
@ 2011-04-05 14:39 ` Viktor Bojović <viktor.bojovic@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Viktor Bojović @ 2011-04-05 14:39 UTC (permalink / raw)
To: John Fabiani <johnf@jfcomputer.com>; +Cc: pgsql-sql
Hi John,
everything you need is stored in these tables:
http://www.postgresql.org/docs/7.4/static/catalog-pg-attribute.html
http://www.postgresql.org/docs/7.4/static/catalog-pg-class.html
http://www.postgresql.org/docs/7.4/static/catalog-pg-namespace.html
On Tue, Apr 5, 2011 at 4:27 PM, John Fabiani <johnf@jfcomputer.com> wrote:
> Hi,
> I would like to have a simple way to retrieve information for a field name.
> By that I mean have some SQL select that will return all the tables a field
> name exist within a database. I did not find anything with google but of
> course google depends on the search string.
>
> Thanks in advance,
> Johnf
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
--
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: is there a refactor
2011-04-05 14:27 is there a refactor John Fabiani <johnf@jfcomputer.com>
@ 2011-04-05 14:44 ` Adrian Klaver <adrian.klaver@gmail.com>
2011-04-05 14:49 ` Re: is there a refactor Peter Steinheuser <psteinheuser@myyearbook.com>
2011-04-05 14:58 ` Re: is there a refactor John Fabiani <johnf@jfcomputer.com>
1 sibling, 2 replies; 5+ messages in thread
From: Adrian Klaver @ 2011-04-05 14:44 UTC (permalink / raw)
To: pgsql-sql; +Cc: John Fabiani <johnf@jfcomputer.com>
On Tuesday, April 05, 2011 7:27:24 am John Fabiani wrote:
> Hi,
> I would like to have a simple way to retrieve information for a field name.
> By that I mean have some SQL select that will return all the tables a field
> name exist within a database. I did not find anything with google but of
> course google depends on the search string.
>
> Thanks in advance,
> Johnf
test(5432)aklaver=>SELECT table_name from information_schema.columns where
column_name = 'id';
table_name
----------------
user_test
table2
table1
hours
jedit_test
topics
t2
stone
serial_test
messages
binary_test
user_test
timestamp_test
role_t
py_test
money_test
lock_test
local_1
lang_test
interval_test
foob
fooa
fldlength
fk_1
default_test
csv_null
check_two
check_test
array_test
(29 rows)
--
Adrian Klaver
adrian.klaver@gmail.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: is there a refactor
2011-04-05 14:27 is there a refactor John Fabiani <johnf@jfcomputer.com>
2011-04-05 14:44 ` Re: is there a refactor Adrian Klaver <adrian.klaver@gmail.com>
@ 2011-04-05 14:49 ` Peter Steinheuser <psteinheuser@myyearbook.com>
1 sibling, 0 replies; 5+ messages in thread
From: Peter Steinheuser @ 2011-04-05 14:49 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@gmail.com>; +Cc: pgsql-sql@postgresql.org, John Fabiani <johnf@jfcomputer.com>
You could also do something like:
select nspname, relname, attname
from pg_attribute a
JOIN pg_class c ON (a.attrelid = c.oid)
JOIN pg_namespace n ON (n.oid = c.relnamespace)
where a.attname ~ 'yourcolumn'
and c.relname !~ 'pg'
and n.nspname not in ('pg_catalog','information_schema')
order by 1,2,3;
I'd functionalize it.
On Tue, Apr 5, 2011 at 10:44 AM, Adrian Klaver <adrian.klaver@gmail.com>wrote:
> On Tuesday, April 05, 2011 7:27:24 am John Fabiani wrote:
> > Hi,
> > I would like to have a simple way to retrieve information for a field
> name.
> > By that I mean have some SQL select that will return all the tables a
> field
> > name exist within a database. I did not find anything with google but of
> > course google depends on the search string.
> >
> > Thanks in advance,
> > Johnf
>
> test(5432)aklaver=>SELECT table_name from information_schema.columns where
> column_name = 'id';
> table_name
> ----------------
> user_test
> table2
> table1
> hours
> jedit_test
> topics
> t2
> stone
> serial_test
> messages
> binary_test
> user_test
> timestamp_test
> role_t
> py_test
> money_test
> lock_test
> local_1
> lang_test
> interval_test
> foob
> fooa
> fldlength
> fk_1
> default_test
> csv_null
> check_two
> check_test
> array_test
> (29 rows)
>
> --
> Adrian Klaver
> adrian.klaver@gmail.com
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
--
Peter Steinheuser
psteinheuser@myyearbook.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: is there a refactor
2011-04-05 14:27 is there a refactor John Fabiani <johnf@jfcomputer.com>
2011-04-05 14:44 ` Re: is there a refactor Adrian Klaver <adrian.klaver@gmail.com>
@ 2011-04-05 14:58 ` John Fabiani <johnf@jfcomputer.com>
1 sibling, 0 replies; 5+ messages in thread
From: John Fabiani @ 2011-04-05 14:58 UTC (permalink / raw)
To: pgsql-sql
On Tuesday, April 05, 2011 07:44:51 am Adrian Klaver wrote:
> On Tuesday, April 05, 2011 7:27:24 am John Fabiani wrote:
> > Hi,
> > I would like to have a simple way to retrieve information for a field
> > name. By that I mean have some SQL select that will return all the
> > tables a field name exist within a database. I did not find anything
> > with google but of course google depends on the search string.
> >
> > Thanks in advance,
> > Johnf
>
> test(5432)aklaver=>SELECT table_name from information_schema.columns where
> column_name = 'id';
> table_name
Wow that was quick - thanks to all!
Johnf
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2011-04-05 14:58 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-04-05 14:27 is there a refactor John Fabiani <johnf@jfcomputer.com>
2011-04-05 14:39 ` Viktor Bojović <viktor.bojovic@gmail.com>
2011-04-05 14:44 ` Adrian Klaver <adrian.klaver@gmail.com>
2011-04-05 14:49 ` Peter Steinheuser <psteinheuser@myyearbook.com>
2011-04-05 14:58 ` John Fabiani <johnf@jfcomputer.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox