我对此仍然很陌生,所以在我学习规则的同时要有耐心。 我遇到了mysql脚本的问题,它给了我一个非常常见的1215错误(无法创建外键)
我已经检查了数据类型,并且外键引用主键,但它仍然无效。
答案 0 :(得分:1)
必须声明如下:
必须首先声明外键:
FOREIGN KEY
// foreignKEY-必须先声明为一列,然后再将其声明为[@
好运。
答案 1 :(得分:0)
您刚刚在引用的表和列的语法中犯了错误。
你写了例如:
Public Sub Main()
Dim sFile As String
Dim i As Integer
Dim bExists As Boolean
i = 1
bExists = True
Dts.Variables("User::UStartTime").Value = Dts.Variables("System::StartTime").Value
Dts.Variables("User::FileName").Value = Dts.Variables("User::Protocol").Value.ToString _
& "_" & CStr(Format(Dts.Variables("User::UStartTime").Value, "yyyyMMdd")) _
& "_" & CStr(i)
Dts.Variables("User::FileLocation").Value = "\\ACMSHARES2\clntrial\DataMgt\" _
& Dts.Variables("User::StudyNumber").Value.ToString _
& "\" + Dts.Variables("User::FileLocation").Value.ToString _
& Dts.Variables("User::FileName").Value.ToString _
& "." & Dts.Variables("User::FileType").Value.ToString
'Add incrementing number to end of file name per DMA
Do Until bExists = False
'SCRIPTING TASK FAILS ON THE NEXT LINE
sFile = Dts.Variables("User::Filelocation").Value
If File.Exists(sFile) Then
i = i + 1
Dts.Variables("User::FileName").Value = Dts.Variables("User::Protocol").Value.ToString _
& "_" & CStr(Format(Dts.Variables("User::UStartTime").Value, "yyyyMMdd")) _
& "_" & CStr(i)
Dts.Variables("User::FileLocation").Value = "\\ACMSHARES2\clntrial\DataMgt\" _
& Dts.Variables("User::StudyNumber").Value.ToString _
& "\" + Dts.Variables("User::FileLocation").Value.ToString _
& Dts.Variables("User::FileName").Value.ToString _
& "." & Dts.Variables("User::FileType").Value.ToString
Else
bExists = False
End If
MsgBox("Loop iterated")
Loop
Dts.TaskResult = ScriptResults.Success
End Sub
应该是:
sFile = Dts.Variables("User::Filelocation").Value
答案 2 :(得分:0)
将REFERENCE key
分配给PERCENTAGE
表时出错。引用键应该是这样的。
FOREIGN KEY (RM_ID) REFERENCES ROOMMATE(RM_Id)
FOREIGN KEY (ITM_Id) REFERENCES ITEM(ITM_Id)
而不是:
FOREIGN KEY (RM_ID) REFERENCES ROOMMATE.RM_Id
FOREIGN KEY (ITM_Id) REFERENCES ITEM.ITM_Id
答案 3 :(得分:0)
我注意到您尚未为主键/唯一约束指定名称,您也可以从外键中省略它们。此外,对于简单(单列)键,您可以将其声明为与列声明一致,例如:剪断示例:
CREATE TABLE ITEM ( ITM_ID INT(3) NOT NULL UNIQUE );
CREATE TABLE PERCENTAGE ( ITM_ID INT(3) NOT NULL REFERENCES ITEM ( ITM_ID ) );