Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> One thing I don't understand in SQL is why creating a tmp table is so verbose, why we can't use type inference.

> There is an internal software where I work where to create a tmp table you just assign the result of the query to a variable. It is so much nicer. So for instance creating a tmp table becomes as simple as the below, no need to declare each columns, to do an insert, to drop the table in the end:

> @t = select colA, colB from tbl

> select top 10 * from @t order by colB

Unless I am misunderstanding what you are looking for, 'SELECT INTO' works the way you want: https://www.postgresql.org/docs/9.1/sql-selectinto.html

It's on every RDBMS I've used, IIRC.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: