From: | "Charles Clavadetscher" <clavadetscher(at)swisspug(dot)org> |
---|---|
To: | "'Sathesh S'" <sathesh(dot)sundaram(at)hotmail(dot)com>, "'pgsql-general'" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Get tables ending with numbers |
Date: | 2017-02-15 06:35:28 |
Message-ID: | 0b3501d28755$b8f74b30$2ae5e190$@swisspug.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello Sathesh
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Sathesh S
> Sent: Mittwoch, 15. Februar 2017 07:17
> To: pgsql-general <pgsql-general(at)postgresql(dot)org>
> Subject: [GENERAL] Get tables ending with numbers
>
> Hi All,
>
> Im trying to get tables ending with numbers (last 8 characters should be numbers).
>
> For example: I have the tables "test_20160215" and "test_20160131" and "test_1". When i run the below sql im not
> getting any output.
>
> Select relname from pg_class where relname like '%[0-9]'
You should use an operator for regexp:
CREATE TABLE test_20160215 (id integer);
CREATE TABLE
SELECT relname FROM pg_class WHERE relname ~ '[0-9]';
relname
---------------
[snip]
test_20160215
[snip]
Or
SELECT relname FROM pg_class WHERE relname ~ 'test_[0-9]+$';
relname
---------------
test_20160215
(1 row)
Regards
Charles
> Can someone please give some idea on this.
>
> Thanks,
> Sathesh
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-02-15 06:35:33 | Re: Get tables ending with numbers |
Previous Message | Sathesh S | 2017-02-15 06:16:51 | Get tables ending with numbers |