2020-12-07 Temporary PostgreSQL tables

Today I have yet another small PostgreSQL tip.

Sometimes you want just to experiment a bit, or maybe move some data around a bit, and then you may have the idea “ok, so I’ll just create this table, do something with it, and then drop it”.

Well – you don’t have to drop it. You can say create temporary table ... (or just create temp table ...) and the table will disappear by itself at the end of the session. Consult the manual to learn more – also how to create a table that only lasts until the end of the current transaction.

Also, notice that if you say \c ... in psql, you create another connection and temporary tables won’t survive that.

That’s it for today!

CategoryEnglish, CategoryBlog, CategoryPostgreSQL