This would be inconsistent for many reasons. One simple example is use of *
to select the column: when you do this
select id, name, birthday, hair_color from person
and get back a table with all four columns present (hair_color
is set to null
on all rows) you would reasonably expect that the query below
select * from person
returned at least four columns, and that hair_color
is among the columns returned. However, this wouldn't be the case if SQL allowed non-existent columns to return null
s.
This would also create hard-to-find errors when a column gets renamed in the schema, but some of the queries or stored procedures do not get re-worked to match the new names.
Generally, though, SQL engine developers make tradeoffs between usability and "hard" error checking. Sometimes, they would relax a constraint or two, to accommodate some of the most common "simple" mistakes (such as forgetting to use an aggregate function in a grouped query; it is an error, but MySql lets you get away with it). When it comes to schema checks, though, SQL engines do not allow any complacency, treating all missing schema elements as errors.