MySql到MSSQL的转换

时间:2015-05-13 19:02:17

标签: mysql sql-server

我在mysql中有这个查询:

DROP TABLE IF EXISTS `ARTICLES`;
CREATE TABLE `ARTICLES` (
  `ART_ID` int(11) NOT NULL,
  `ART_ARTICLE_NR` varchar(66) NOT NULL,
  `ART_SUP_ID` smallint(6) DEFAULT NULL,
  `ART_DES_ID` int(11) DEFAULT NULL,
  `ART_COMPLETE_DES_ID` int(11) DEFAULT NULL,
  `ART_PACK_SELFSERVICE` smallint(6) DEFAULT NULL,
  `ART_MATERIAL_MARK` smallint(6) DEFAULT NULL,
  `ART_REPLACEMENT` smallint(6) DEFAULT NULL,
  `ART_ACCESSORY` smallint(6) DEFAULT NULL,
  `ART_BATCH_SIZE1` int(11) DEFAULT NULL,
  `ART_BATCH_SIZE2` int(11) DEFAULT NULL,
  PRIMARY KEY (`ART_ID`),
  KEY `ART_SUP_ID` (`ART_SUP_ID`),
  KEY `ART_DES_ID` (`ART_DES_ID`),
  KEY `ART_COMPLETE_DES_ID` (`ART_COMPLETE_DES_ID`),
  KEY `ART_ARTICLE_NR` (`ART_ARTICLE_NR`(18))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

我想要这个MSSQL版本。我还读到了SSMA转换器。

1 个答案:

答案 0 :(得分:0)

IF OBJECT_ID('ARTICLES','U') IS NOT NULL
  DROP TABLE ARTICLES;
GO

CREATE TABLE ARTICLES 
(
  ART_ID                INT NOT NULL PRIMARY KEY,
  ART_ARTICLE_NR        varchar(66) NOT NULL,
  ART_SUP_ID            INT ,
  ART_DES_ID            INT ,
  ART_COMPLETE_DES_ID   INT ,
  ART_PACK_SELFSERVICE  INT ,
  ART_MATERIAL_MARK     INT ,
  ART_REPLACEMENT       INT ,
  ART_ACCESSORY         INT ,
  ART_BATCH_SIZE1       INT ,
  ART_BATCH_SIZE2       INT 
);
GO

/*
  KEY ART_SUP_ID (ART_SUP_ID),
  KEY ART_DES_ID (ART_DES_ID),
  KEY ART_COMPLETE_DES_ID (ART_COMPLETE_DES_ID),
  KEY ART_ARTICLE_NR (ART_ARTICLE_NR(18))
*/

对于这些索引,您需要在单独的SQL语句中创建它们。例如,SQL Server等效于" KEY ART_SUP_ID(ART_SUP_ID)"将是

CREATE INDEX IX_SomeIdexName 
ON ARTICLES (ART_SUP_ID)
GO
对于mysql语句中的每个键语句,

...等等。