B
B
beduin012018-04-05 11:23:03
SQLite
beduin01, 2018-04-05 11:23:03

Why doesn't the ForeignKey constraint work in SQLite?

I can not understand why the restriction on ForeignKey in SQLite does not work. My schema:

CREATE TABLE "address"(
  "id" Integer NOT NULL PRIMARY KEY,
  "email" Text,
CONSTRAINT "unique_id" UNIQUE ( "id" ) );

CREATE TABLE "mans"(
  "id" Integer NOT NULL PRIMARY KEY,
  "mail_id" Integer,
  "name" Text,
  "age" Integer,
  CONSTRAINT "mans_address_NO ACTION_NO ACTION_mail_id_id_0" FOREIGN KEY ( "mail_id" ) REFERENCES "address"( "id" )
 );

However, the following queries work:
INSERT INTO "address" ( "email", "id")  VALUES ( '[email protected]', 4 );

INSERT INTO "mans" ("id", "mail_id", "name") VALUES ( 1 , 2 , 'mike' );

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question