创建外键SQL [英] Create Foreign Key SQL
本文介绍了创建外键SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建一个外键
从表tGeoAnswers列'locationId'
到表tLocations ''''''$'$'$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $'$' FOREIGN KEY
(locationId)
REFERENCES
tLocations(id)
我试图找到这个代码,但是我得到了以下错误:
列的定义必须包含一个数据类型
解决方案
ALTER TABLE tGeoAnswers ADD CONSTRAINT FK_Answer_Location ...
$否则,假设你正在添加一个名为
FK_Answer_Location
的列。
$ b
How do I create a foreign key
from table tGeoAnswers column 'locationId'
to table tLocations column 'id'?
ALTER TABLE
tGeoAnswers
ADD
FK_Answer_Location
FOREIGN KEY
(locationId)
REFERENCES
tLocations(id)
I am trying this code that I found but I get the following error:
The definition for column 'FK_Answer_Location' must include a data type
解决方案
ALTER TABLE tGeoAnswers ADD CONSTRAINT FK_Answer_Location ...
Otherwise it assumes you're adding a column called FK_Answer_Location
.
这篇关于创建外键SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文