Skip to main content
removed specific version: this limitation is still there today, and no change is in sight
Source Link
Wolf
  • 10.3k
  • 8
  • 70
  • 116

How do I add a foreign key to an existing sqlite (3.6.21)SQLite table?

I have the following table:

CREATE TABLE child( 
  id INTEGER PRIMARY KEY, 
  parent_id INTEGER, 
  description TEXT);

How do I add a foreign key constraint on parent_idparent_id? Assume foreign keys are enabled.

Most examples assume you're creating the table - I'd like to add the constraint to an existing one.

How do I add a foreign key to an existing sqlite (3.6.21) table?

I have the following table:

CREATE TABLE child( 
  id INTEGER PRIMARY KEY, 
  parent_id INTEGER, 
  description TEXT);

How do I add a foreign key constraint on parent_id? Assume foreign keys are enabled.

Most examples assume you're creating the table - I'd like to add the constraint to an existing one.

How do I add a foreign key to an existing SQLite table?

I have the following table:

CREATE TABLE child( 
  id INTEGER PRIMARY KEY, 
  parent_id INTEGER, 
  description TEXT);

How do I add a foreign key constraint on parent_id? Assume foreign keys are enabled.

Most examples assume you're creating the table - I'd like to add the constraint to an existing one.

Fix trivial typo
Link
Jonathan Leffler
  • 759k
  • 145
  • 961
  • 1.3k

How do I add a foriegnforeign key to an existing sqlite (3.6.21) table?

edited tags
Link
Daniel Vassallo
  • 345.6k
  • 72
  • 513
  • 447
Source Link
Dane O'Connor
  • 77.8k
  • 41
  • 122
  • 174
Loading