将MySQL转储文件导入MSSQL [英] Import MySQL dump file into MSSQL
问题描述
Browsermob / Neustar生成一个MySQLdump文件,您可以使用该文件查询负载测试数据,而不会产生云时间(这是自然可计费的)。转储文件是一个标准的转储文件,虽然我知道mysqldump有一个 compatible = mssql选项,我显然无法自己运行。使用文本编辑器查看文件的内容(非常大)似乎显示了一系列以大量批量插入结尾的SQL语句。我试图在Microsoft SQL Management Studio中打开该文件,但它崩溃了(已知错误),因为文件太大了。
Browsermob / Neustar produces a MySQLdump file that you can use to query load test data without incurring cloud hours (which are naturally billable). The dump file is a standard dump file, and although I understand that mysqldump has a compatible=mssql option, I am obviously not in a position to run that myself. Looking at the contents of the file (which is extremely large) using a text editor seems to show a series of SQL statements ending in a massive bulk insert. I tried to open the file in Microsoft SQL Management Studio but it crashed (known bug) because the file was too large.
那么,是否有人知道将使用的工具将MySQL转储文件导入MsSQL。我能想到的唯一选择是安装MySQL并将转储文件导入到该文件中然后通过ODBC传输数据,但我真的不想安装MySQL,除非我必须这样做。
So, does anyone know of a tool that will import the MySQL dump file into MsSQL. The only options I can think of are to install MySQL and import the dump file into that instead and then transfer the data over ODBC, but I really don't want to install MySQL unless I have to.
重要:所以,为了清楚,我有一个转储文件,没有别的,我无法访问数据库,也没有用任何选项重新运行转储。我必须使用我收到的文件。
有什么想法吗?
首先该文件的行如下所示:
First lines of the file look like this:
-- MySQL dump 10.13 Distrib 5.1.58, for debian-linux-gnu (i686)
--
-- Host: localhost Database: collector
-- ------------------------------------------------------
-- Server version 5.1.58-1ubuntu1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `name_value_pairs`
--
DROP TABLE IF EXISTS `name_value_pairs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `name_value_pairs` (
`id` int(8) unsigned DEFAULT NULL,
`tx_id` char(24) NOT NULL,
`step_id` int(8) unsigned DEFAULT NULL,
`name` varchar(100) NOT NULL,
`value` varchar(100) DEFAULT NULL,
KEY `name_value_pairs_id` (`id`),
KEY `name_value_pairs_tx_id` (`tx_id`),
KEY `name_value_pairs_step_id` (`step_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `name_value_pairs`
--
LOCK TABLES `name_value_pairs` WRITE;
/*!40000 ALTER TABLE `name_value_pairs` DISABLE KEYS */;
/*!40000 ALTER TABLE `name_value_pairs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `object`
--
DROP TABLE IF EXISTS `object`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `object` (
`bytes` int(10) unsigned NOT NULL,
`domain` varchar(255) NOT NULL,
`end_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`err_msg` varchar(255) DEFAULT NULL,
`host` varchar(255) NOT NULL,
`method` varchar(16) DEFAULT NULL,
`obj_id` int(8) unsigned NOT NULL,
`obj_num` mediumint(4) unsigned NOT NULL,
`path` varchar(4096) NOT NULL,
`partial_url_md5` varchar(32) NOT NULL,
`protocol` varchar(16) NOT NULL,
`resolved_ip_addr` varchar(255) DEFAULT NULL,
`start_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`status_code` smallint(4) NOT NULL,
`step_id` int(8) unsigned NOT NULL,
`time_active` mediumint(6) unsigned DEFAULT NULL,
`blocked_time` mediumint(6) unsigned DEFAULT NULL,
`dns_lookup_time` mediumint(6) unsigned DEFAULT NULL,
`connect_time` mediumint(6) unsigned DEFAULT NULL,
`ssl_handshake_time` mediumint(6) unsigned DEFAULT NULL,
`send_time` mediumint(6) unsigned DEFAULT NULL,
`time_to_first_byte` mediumint(6) unsigned DEFAULT NULL,
`receive_time` mediumint(6) unsigned DEFAULT NULL,
`tx_id` char(24) NOT NULL,
`url` varchar(4096) NOT NULL,
KEY `object_partial_url_md5` (`partial_url_md5`),
KEY `object_obj_id` (`obj_id`),
KEY `object_obj_num` (`obj_num`),
KEY `object_step_id` (`step_id`),
KEY `object_tx_id` (`tx_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `object`
--
LOCK TABLES `object` WRITE;
/*!40000 ALTER TABLE `object` DISABLE KEYS */;
然后是批量插入。
推荐答案
该文件中的信息仅用于删除和重新创建数据库的模式(我假设您已经拥有),因此您可能不需要它。
This information in the file is only to delete and recreate the schema of the database (that I assume you already have), so you probably don't need that.
批量插入部分很有意思,可能你可以将每个表的那个部分隔离到不同的文件并使用BULK INSERT从T-SQL上传到MsSQL,你可以定义分隔符和其他这个BULK插入的设置你应该适合你的任何格式..
The bulk insert part is the interesting, probably you can isolate that part for each table to different files and upload it to MsSQL with BULK INSERT from T-SQL, you are able to define delimiter and other settings for this BULK insert you it should fit whatever format you have..
这篇关于将MySQL转储文件导入MSSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!