SQLite 3类型名称和关键字在定义中是否区分大小写?

即以下声明是否相同?

CREATE TABLE example_table (
  id INTEGER PRIMARY KEY,
  name TEXT
)

create table example_table (
  id integer primary key,
  name text
)

我认为大写是痛苦的编辑,但我已经发现交互模式中的.schema命令会记住这种情况.文档也总是使用大写版本.

最佳答案 我使用此代码测试它,似乎名称不区分大小写:

CREATE TABLE table_sensitive (
       id INTEGER PRIMARY KEY,
       some_int INTEGER,
       some_text TEXT
);

create table table_insensitive (
       id integer primary key,
       some_int integer,
       some_text text
);

INSERT INTO table_sensitive ( id, some_int, some_text )
       VALUES ( 'not an integer key', 'a value', 123 );

insert into table_insensitive ( id, some_int, some_text )
       values ( 'not an integer key', 'a value', 123 );

INSERT INTO table_sensitive ( id, some_int, some_text )
       VALUES ( 0, '123', 123 );

insert into table_insensitive ( id, some_int, some_text )
       values ( 1, '123', 123 );

SELECT typeof(id), typeof(some_int), typeof(some_text) FROM table_sensitive;
select typeof(id), typeof(some_int), typeof(some_text) from table_insensitive;

结果是:

Error: near line 13: datatype mismatch
Error: near line 16: datatype mismatch
integer|integer|text
integer|integer|text

(对于具有非整数主键的插入有错误,类型转换适用于包含两个版本的整数的字符串.)

这意味着您几乎可以编写小写的关键字和类型,这是我想知道的.

点赞