我想在MySql中转换以下内容:
`DROP TABLE IF EXISTS `concepts_snapshot`;
CREATE TABLE IF NOT EXISTS `concepts_snapshot` (
`id` bigint(18) NOT NULL,
`effectivetime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`active` int(1) NOT NULL,
`moduleid` bigint(18) NOT NULL,
`definitionstatusid` bigint(18) NOT NULL,
PRIMARY KEY (`id`,`effectivetime`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
DROP TABLE IF EXISTS `descriptions_snapshot`;
CREATE TABLE IF NOT EXISTS `descriptions_snapshot` (
`id` bigint(18) NOT NULL,
`effectivetime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`active` int(1) NOT NULL,
`moduleid` bigint(18) NOT NULL,
`conceptid` bigint(18) NOT NULL,
`languagecode` varchar(10) collate utf8_unicode_ci NOT NULL,
`typeid` bigint(18) NOT NULL,
`term` varchar(2048) collate utf8_unicode_ci NOT NULL,
`casesignificanceid` bigint(18) NOT NULL,
PRIMARY KEY (`id`,`effectivetime`),
CONSTRAINT FOREIGN KEY (conceptid) REFERENCES concepts_snapshot(id) ON DELETE CASCADE,
CONSTRAINT FOREIGN KEY (moduleid) REFERENCES concepts_snapshot(id) ON DELETE CASCADE,
CONSTRAINT FOREIGN KEY (typeid) REFERENCES concepts_snapshot(id) ON DELETE CASCADE
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;`
到MS Sql Server。到目前为止,我有以下内容:
DROP TABLE IF EXISTS [concepts_snapshot]
GO
CREATE TABLE [concepts_snapshot] (
[id] bigint NOT NULL,
[effectivetime] datetimeoffset NOT NULL default CURRENT_TIMESTAMP,
[active] int NOT NULL,
[moduleid] bigint NOT NULL,
[definitionstatusid] bigint NOT NULL,
CONSTRAINT PK_ConceptsSnapshot PRIMARY KEY ([id], [effectivetime])
)
GO
DROP TABLE IF EXISTS [descriptions_snapshot]
GO
CREATE TABLE [descriptions_snapshot] (
[id] bigint NOT NULL,
[effectivetime] datetimeoffset NOT NULL default CURRENT_TIMESTAMP,
[active] int NOT NULL,
[moduleid] bigint NOT NULL,
[conceptid] bigint NOT NULL,
[languagecode] nvarchar(10) NOT NULL,
[typeid] bigint NOT NULL,
[term] nvarchar(2048) NOT NULL,
[casesignificanceid] bigint NOT NULL
CONSTRAINT PK_DescriptionsSnapshot PRIMARY KEY ([id],[effectivetime]),
CONSTRAINT FK_ConceptsSnapshot_DescriptionsSnapshot_ConceptId FOREIGN KEY (conceptid) REFERENCES concepts_snapshot(id) ON DELETE CASCADE,
CONSTRAINT FK_ConceptsSnapshot_DescriptionsSnapshot_ModuleId FOREIGN KEY (moduleid) REFERENCES concepts_snapshot(id) ON DELETE CASCADE,
CONSTRAINT FK_ConceptsSnapshot_DescriptionsSnapshot_TypeId FOREIGN KEY (typeid) REFERENCES concepts_snapshot(id) ON DELETE CASCADE
)
GO
但是,我遇到了外键约束问题,并收到以下错误消息。
在引用表'concepts_snapshot'中没有与外键'FK_ConceptsSnapshot_DescriptionsSnapshot_ConceptId'中的引用列列表匹配的主键或候选键。
我该如何解决?
干杯