backendgym backendgym · reps Sign in with GitHubSign in

04Compare temporary and inline

sql-viewing / reps/04/README.md

For the active collections created in 2022 or later, return the titles twice: once through a temporary view and once through a CTE. Then, in the same file, so in the same session, query pg_views for your temporary view and for collection_analysis.

Expected: both results have 2 rows, Blue Room and Bronze Dog. In pg_views, collection_analysis is under the public schema (along with any views you kept from earlier reps), while the temporary view is under a pg_temp_N schema and disappears when the session ends.

After the rep
  1. 1 Your CTE and your temporary view returned the same rows. Which of the two could a later query in the same session reuse, and which one only lives inside its own statement?