references创建表时如何使用关键字?
references
假设我要创建两个表person,hobby并且我希望业余爱好表ID引用人员的ID?
person
hobby
person table - id - name hobby - id - person_id - hobby_name
我怎么做?
与此类似,创建兴趣表:
CREATE TABLE hobby ( id INT NOT NULL AUTO_INCREMENT, person_id INT NOT NULL, hobby_name VARCHAR(255), PRIMARY KEY(id), FOREIGN KEY(person_id) REFERENCES person(id))