【发布时间】:2017-08-02 00:35:42
【问题描述】:
有人能解释一下为什么下面的 SQLite 会话中的引用约束似乎不起作用吗?这是在 Windows 10 上使用 sqlite3 的真实但简单的会话。您可以在会话中看到打印的 SQLite 版本:
C:\Users\johnd> sqlite3 -version
3.19.3 2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b
C:\Users\johnd> sqlite3
SQLite version 3.19.3 2017-06-08 14:26:16
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table parent (
...> id integer primary key,
...> name text);
sqlite> create table child (
...> id integer primary key,
...> parent_id integer references parent(id),
...> description text);
sqlite> insert into parent (id, name) values(1, 'Bob');
sqlite> insert into parent (id, name) values(2, 'Sally');
sqlite> insert into child (id, parent_id, description) values(1, 3, 'bad ref');
sqlite> select * from parent;
1|Bob
2|Sally
sqlite> select * from child;
1|3|bad ref
sqlite> .exit
C:\Users\johnd>
【问题讨论】:
标签: sqlite