mysql> create table products(id integer unsigned auto_increment primary key);
Query OK, 0 rows affected (0.05 sec)
mysql> CREATE TABLE orders (
-> id integer PRIMARY KEY auto_increment,
-> product_id integer REFERENCES products (id),
-> quantity integer,
-> INDEX product_id_idx (product_id)
-> );
Query OK, 0 rows affected (0.05 sec)
mysql> insert into orders(product_id,quantity) value(1,1);
Query OK, 1 row affected (0.00 sec)
Since product 1 doesn't exist,the insert
statement is supposed to fail,but in fact not.
Why?