Database Tools: SQLite Manager (V0.7.7)
SQLite version: v3.6.19+
SQLite Manager does not open the foreign key by default.
So how do you use it to create a table with a foreign key?
First, open the foreign key support 1. Open "On-connect SQL tab"
"Tools", "Open on-connect SQL Tab"
2. In the "On-connect SQL tab" Input command
PRAGMA Foreign_keys=on;
3. Check if foreign key support is turned on
Click on the "DB Settings" tab to view
The "on" in the figure indicates that the foreign key function has been turned on
II. Building Tables by format
CREATE TABLE child_table_name (field_1 integer PRIMARY KEY, field_2 TEXT, Foreign_key_field Integer, Foreign KEY (foreign_ Key_field) REFERENCES Parent_table_name (Parent_key_field));
Note that: In the construction of the table, be sure to add the foreign key in the field, otherwise it will be an error.
Artist.sql
CREATE TABLE artist ( ArtistID INTEGER PRIMARY KEY, artistname TEXT);
Track.sql
CREATE TABLE Track ( trackid Integer, trackname TEXT, trackartist Integer, FOREIGN KEY ( trackartist) REFERENCES artist (ArtistID));
Reference article: 1. SQLite Foreign Key support 2. Foreign Keys in SQLite Manager 3. On Connect SQL Tab for SQLite Manager 4. Execute SQL Tab