CREATE TABLE account_mygraph ( id integer NOT NULL PRIMARY KEY AUTOINCREMENT, profile_id integer NOT NULL, name character varying(64) NOT NULL, url text NOT NULL, FOREIGN KEY (profile_id) REFERENCES account_profile(id) DEFERRABLE INITIALLY DEFERRED );
而不能是:
1 2 3 4 5 6 7 8
CREATE TABLE account_mygraph ( id integer NOT NULL AUTOINCREMENT, profile_id integer NOT NULL, name character varying(64) NOT NULL, url text NOT NULL, PRIMARY KEY (id), FOREIGN KEY (profile_id) REFERENCES account_profile(id) DEFERRABLE INITIALLY DEFERRED );
导入 schema 和 数据 到 sqlite 中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
~$ sqlite3 example.db SQLite version 3.11.0 2016-02-15 17:29:24 Enter ".help"for usage hints. sqlite> .read schema.sql
sqlite> .read data.sql
sqlite> .schema CREATE TABLE account_mygraph ( id integer NOT NULL PRIMARY KEY AUTOINCREMENT, profile_id integer NOT NULL, name character varying(64) NOT NULL, url text NOT NULL, FOREIGN KEY (profile_id) REFERENCES account_profile(id) DEFERRABLE INITIALLY DEFERRED ); ...