pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Postgres - search for value throughout many tables?
6+ messages / 6 participants
[nested] [flat]

* Postgres - search for value throughout many tables?
@ 2018-08-08 14:09  czezz <czezz@o2.pl>
  0 siblings, 3 replies; 6+ messages in thread

From: czezz @ 2018-08-08 14:09 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi everyone,  I want to aks if anyone knows is there a way to search for specific &#34;value&#34; throughout list of tables OR all tables in databse?   Cheers,  czezz

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Postgres - search for value throughout many tables?
@ 2018-08-08 14:13  David G. Johnston <david.g.johnston@gmail.com>
  parent: czezz <czezz@o2.pl>
  2 siblings, 1 reply; 6+ messages in thread

From: David G. Johnston @ 2018-08-08 14:13 UTC (permalink / raw)
  To: czezz <czezz@o2.pl>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wednesday, August 8, 2018, czezz <czezz@o2.pl> wrote:

> Hi everyone,
> I want to aks if anyone knows is there a way to search for specific
> "value" throughout list of tables OR all tables in databse?
>

Can you pg_dump your database to plain text and search that?  Nothing built
in provides that ability though you possibly could work up something using
dynamic sql.

David J.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Postgres - search for value throughout many tables?
@ 2018-08-08 14:33  Achilleas Mantzios <achill@matrix.gatewaynet.com>
  parent: czezz <czezz@o2.pl>
  2 siblings, 0 replies; 6+ messages in thread

From: Achilleas Mantzios @ 2018-08-08 14:33 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

If the num of tables is smallish you could run smth like

select * from (
select table1::text as thecol from table1
UNION select table2::text FROM table2
UNION select table3::text FROM table3
UNION .....
) as qry WHERE thecol ~* 'some pattern';

On 08/08/2018 17:09, czezz wrote:
> Hi everyone,
> I want to aks if anyone knows is there a way to search for specific "value" throughout list of tables OR all tables in databse?
>
> Cheers,
> czezz


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Postgres - search for value throughout many tables?
@ 2018-08-08 17:16  Christopher Browne <cbbrowne@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Christopher Browne @ 2018-08-08 17:16 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: czezz@o2.pl; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wed, 8 Aug 2018 at 10:14, David G. Johnston
<david.g.johnston@gmail.com> wrote:
>
> On Wednesday, August 8, 2018, czezz <czezz@o2.pl> wrote:
>>
>> Hi everyone,
>> I want to aks if anyone knows is there a way to search for specific "value" throughout list of tables OR all tables in databse?
>
>
> Can you pg_dump your database to plain text and search that?  Nothing built in provides that ability though you possibly could work up something using dynamic sql.

If there are some tables that are extraordinarily large that would not
be good candidates, this could be excessively expensive.

If you can identify a specific set of tables that are good candidates,
then a faster option might involve:
  pg_dump --data-only --table=this_table --table=that_table
--table=other_table databaseURI

or, if there are only a few tables to omit...
  pg_dump --data-only --exclude-table=this_irrelevant_big_table
--exclude-table=another_big_irrelevant_table databaseURI

-- 
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Postgres - search for value throughout many tables?
@ 2018-08-10 09:59  Adrien NAYRAT <adrien.nayrat@anayrat.info>
  parent: czezz <czezz@o2.pl>
  2 siblings, 1 reply; 6+ messages in thread

From: Adrien NAYRAT @ 2018-08-10 09:59 UTC (permalink / raw)
  To: czezz <czezz@o2.pl>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>; +Cc: Daniel Verite <daniel@manitou-mail.org>

On 08/08/2018 04:09 PM, czezz wrote:
> Hi everyone,
> I want to aks if anyone knows is there a way to search for specific 
> "value" throughout list of tables OR all tables in databse?
> 
> Cheers,
> czezz

Hello,

Maybe this article by Daniel could help you : 
https://blog-postgresql.verite.pro/2017/06/06/global-search.html

Unfortunately it is not translated, you have to play with a translate tool.

Regards,




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Postgres - search for value throughout many tables?
@ 2018-08-10 10:34  Daniel Verite <daniel@manitou-mail.org>
  parent: Adrien NAYRAT <adrien.nayrat@anayrat.info>
  0 siblings, 0 replies; 6+ messages in thread

From: Daniel Verite @ 2018-08-10 10:34 UTC (permalink / raw)
  To: czezz <czezz@o2.pl>; +Cc: pgsql-general@lists.postgresql.org; Adrien NAYRAT <adrien.nayrat@anayrat.info>

	Adrien NAYRAT wrote:

> On 08/08/2018 04:09 PM, czezz wrote:
> > Hi everyone,
> > I want to aks if anyone knows is there a way to search for specific 
> > "value" throughout list of tables OR all tables in databse?
> > 
> > Cheers,
> > czezz
> 
> Hello,
> 
> Maybe this article by Daniel could help you : 
> https://blog-postgresql.verite.pro/2017/06/06/global-search.html
> 
> Unfortunately it is not translated, you have to play with a translate tool.

You may also get the code and README from here:
https://github.com/dverite/postgresql-functions/tree/master/global_search


Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2018-08-10 10:34 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-08 14:09 Postgres - search for value throughout many tables? czezz <czezz@o2.pl>
2018-08-08 14:13 ` David G. Johnston <david.g.johnston@gmail.com>
2018-08-08 17:16   ` Christopher Browne <cbbrowne@gmail.com>
2018-08-08 14:33 ` Achilleas Mantzios <achill@matrix.gatewaynet.com>
2018-08-10 09:59 ` Adrien NAYRAT <adrien.nayrat@anayrat.info>
2018-08-10 10:34   ` Daniel Verite <daniel@manitou-mail.org>

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