1

I sometimes encounter this SELECT statement (in JSON-related answers on stackexchanges):

SELECT my_table
FROM my_table;

It seems to turn a one-column result, with multiple rows.

What would be the name of the type of each row returned? A row value of my_table?

(I tried reading the documentation (sql-expressions) but, I could not find a specific answer.)

2

It's a named composite type: https://www.postgresql.org/docs/current/static/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS

When you create a table, a TYPE with the same name is created.

A row of that table is of that type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.