QuestenaПрактика, после которой понятно, что повторить
Вопрос 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. 6Правильный ответ
  4. 3

Объяснение

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.

Продолжить работу с тестом

Начать тренировку
Вопрос 11: In PostgreSQL 18, table na has columns (a_id, label) and 3… · SQL: NULL, Joins and Aggregates · Questena