How to use the keyword 'references' in MySQL?

后端 未结 5 998
庸人自扰
庸人自扰 2020-12-13 19:08

How is the references keyword used when creating a table?

Let\'s say I want to create two tables person and hobby and I want t

5条回答
  •  春和景丽
    2020-12-13 19:25

    Here is an example of how you can use it.

    create table hobby(id int references person(id),person_id int,hobby_varchar(20), primary key(id));
    

    For what it means, references allows us to to specify the target table column to which a foreign key refers.

提交回复
热议问题