Javatpoint Logo
Javatpoint Logo

SQLite Foreign Keys

SQLite Foreign Key is used to specify that values in one table also appear in another table. It enforces referential integrity within SQLite database. The referenced table is known as parent table while the table with the foreign key is known as child table. The foreign key in the child table will generally reference a primary key in the parent table.

You can define a foreign key only in CREATE TABLE statement.


Create Foreign Key

Syntax:

Example:

Create a table "departments" having a foreign key.

Here a primary key department_id is created on the departments table. Then a foreign key called fk_departments is created on the employees table that references the departments table based on the department_id field.


Next TopicSQLite Import




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA