QuestenaPractice that shows what to review next
Question 11

In PostgreSQL 18, table na has columns (a_id, label) and 3 rows, table nb has columns (b_id, note) and 2 rows, and the two tables share no column name. How many rows does SELECT * FROM na NATURAL JOIN nb; return?

  1. It raises an error because there is no common column
  2. 0
  3. 6Correct answer
  4. 3

Explanation

NATURAL builds a USING list from the column names present in both tables; when that list is empty there is no join condition left and the statement degenerates into a Cartesian product of 3 x 2 rows. Expecting an error or zero rows assumes PostgreSQL treats a missing common column as a failure, which is exactly why NATURAL is risky under schema change.

Continue with this test

Start practice
Question 11: In PostgreSQL 18, table na has columns (a_id, label) and 3… · SQL: NULL, Joins and Aggregates · Questena