SQLite accepts non-existing join types in SQL syntax
I found this unexpected behavior with SQLite. It appears that SQLite accepts arbitrary keywords in SQL join syntax. If I accidentally type nautral join instead of natural join a cartesian product is produced. Is this the expected behavior开发者_JAVA百科, a feature or a bug?
select count(*) from pri; -- 22
select count(*) from sec; -- 57458
select count(*) from pri natural join sec; -- 57458
select count(*) from pri nautral join sec; -- 1264076
select count(*) from pri advanced natural join sec; -- 57458
select count(*) from pri imaginary join sec; -- 1264076
Tested with SQLite 3.7.3 on Debian 6.0 and SQLite 3.7.5 on Windows 7.
To add: SQLite is an excellent piece of database software and I recommend it from small to medium size projects. Here is my brief SQLite vs PostgreSQL comparison.
nautral
and imaginary
are parsed as aliases to the table:
select count(*) from (pri) natural join sec; -- 57458
select count(*) from (pri AS nautral) join sec; -- 1264076
select count(*) from (pri AS advanced) natural join sec; -- 57458
select count(*) from (pri AS imaginary) join sec; -- 1264076
精彩评论