| From: | Thom Brown <thom(at)linux(dot)com> |
|---|---|
| To: | alain bourgeois <a(dot)bourgeois(at)zetescards(dot)be> |
| Cc: | Dave Page <dpage(at)pgadmin(dot)org>, pgadmin-support(at)lists(dot)postgresql(dot)org |
| Subject: | Re: ? bug pg 9.6 |
| Date: | 2017-08-25 13:23:56 |
| Message-ID: | CAA-aLv5TZt0PQhLffiofBOw7wW_q7FCsYF29B-KEhHyKDKTfwQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgadmin-support |
On 25 August 2017 at 13:19, alain bourgeois <a(dot)bourgeois(at)zetescards(dot)be> wrote:
> But t1 is not in the select list... (and this doesn't work in oracle nor
> mariadb)... It is "strange" but not blocking.
You can refer to the whole table like you would with columns in a
query, so it's valid.
For example:
SELECT tablename
FROM tablename;
This will return the table's data as a single column, the type of
which is the table itself.
SELECT DISTINCT (tablename) tablename, count(*)
FROM tablename
GROUP BY tablename
HAVING count(*) > 1
ORDER BY tablename;
This will effectively show you which rows are duplicated, and how many
times they are duplicated.
And being able to pass the table to a function can be really useful.
For example:
SELECT to_jsonb(tablename) FROM tablename;
This will output the table data as JSON, and use the column names as the keys.
Thom
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alban Hertroys | 2017-08-28 14:03:34 | Dashboard gets stuck |
| Previous Message | Dave Page | 2017-08-25 12:46:26 | Re: ? bug pg 9.6 |