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)
|
|
|
||
|
|
|
|
对于外键,
另外虽然Inline REFERENCES属于SQL标准,但是MySQL目前并不支持或无法识别。 综合上述3点,要改成如下:
|
|||
|
|
