In the current tip of trunk it pretends the unknown tokens are surrounded by double-quotes. Until you interpose a non type keyword ... at which point the parser stops "eating your junk as the type declaration" and resumes the grammar ..
sqlite> create table x(x happy days); sqlite> pragma table_info(x); 0|x|happy days|0||0 sqlite> create table y(x happy not days); Error: near "days": syntax error sqlite> create table y(x happy integer days); sqlite> pragma table_info(y); 0|x|happy integer days|0||0 sqlite> create table z(x happy dumbledorf the wood elf integer days); sqlite> pragma table_info(z); 0|x|happy dumbledorf the wood elf integer days|0||0 Presumably this is so you can do things like: create table x(x datetime text); -- the affinity of the column is text rather than create table x(x "datetime text"); -- the affinity of the column is text However, AS does not "eat your junk" and you have to use quotes to embed spaces in the column/type string ... sqlite> select x as dingbat french fries from x; Error: near "french": syntax error sqlite> select x as "dingbat french fries" from x; 1 --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Simon Slavin >Sent: Wednesday, 27 June, 2018 17:07 >To: SQLite mailing list >Subject: Re: [sqlite] column types and constraints > >On 27 Jun 2018, at 11:56pm, Mark Wagner <m...@google.com> wrote: > >> I recently pointed out that sqlite doesn't enforce type names and >> constraints when creating tables but I was unable to >explain/justify this >> behavior. I'm sure this has come up before and there's a clear >answer but >> I didn't find it easily. > >The usual answer for these things is backward compatiibility. The >bug existed for so long before it was spotted that SQLite3 must >continue to support it. Roll on SQLite4. > >> For example this is accepted without error: CREATE TABLE bar2 (x >happy >> days); > >You can analyse what's actually happening: > >SQLite version 3.22.0 2017-12-05 15:00:17 >sqlite> CREATE TABLE bar2 (x happy days); >sqlite> .headers on >sqlite> .mode column >sqlite> PRAGMA table_info(bar2); >cid name type notnull dflt_value pk >---------- ---------- ---------- ---------- ---------- --------- >- >0 x happy >days 0 0 > >The interpretation is that the first two words are a columnname and >type, and the third word is a column ID, which is not useful. And >there's some sort of formatting bug in the CLI. :-( > >So don't do that. > >Simon. >_______________________________________________ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users