bitsCN.com
mysql数据导入sqlserver数据库方法
方法一:通过在mysql中备份sql来将mysql数据导入sqlserver。适合于数据量不大的情况使用(如何你的数据中存在的blob字段的数据量不是很多或者不存在可以考虑)。
特点:对于小数据量的迁移:方便快捷。
步骤:1:使用mysql工具备份sql文件,我这里用的是SQLyog软件。
2:对备份的sql文件进行处理(原因是这些备份的sql文件可以在sqlserver解析器中不能通过需要进行写修改)。此处以SQLyog举例:
/*!40101 SET NAMES utf8 */;/*!40101 SET SQL_MODE=''*/;/*!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 */;/*Data for the table `t_standard_check_unit` */insert into `t_standard_check_unit`(`SYSTEM_ID`,`UNIT_TYPE_1`,`UNIT_TYPE_2`,`UNIT_TYPE_3`,`UNIT_TYPE_4`,`UNIT_TYPE_5`,`UNIT_TYPE_6`) values ('01',9,7,6,8,4,NULL),('02',9,8,6,5,4,NULL),('03',9,8,5,6,4,NULL),('04',9,8,5,6,4,NULL),('05',9,8,6,5,4,NULL),('06',9,8,5,6,4,NULL),('07',9,9,9,8,4,NULL),('08',9,8,6,5,4,NULL),('09',9,9,9,8,4,NULL);/*Data for the table `t_standard_system` */
上面是备份的sql文件中的部分:
注意:a:其中insert into `t_standard_check_unit`(`SYSTEM_ID`,`UNIT_TYPE_1`,`UNIT_TYPE_2`,`UNIT_TYPE_3`,`UNIT_TYPE_4`,`UNIT_TYPE_5`,`UNIT_TYPE_6`)这一段中的引号在sqlserver中不能支持所以得通过程序处理掉。
处理程序:
public void switchSqlFile(File file) throws IOException{ BufferedReader bReader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"utf-8")); String filePathOld = file.getAbsolutePath(); String filePath = filePathOld.substring(0,filePathOld.indexOf(".")) + "_switchFile" + filePathOld.substring(filePathOld.indexOf(".")); BufferedWriter bWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filePath)),"utf-8")); String str = ""; while((str =bReader.readLine()) !=null){ if(str.contains("CREATE DATABASE")) continue; if(str.contains("USE `q9`")) continue; if(str.toLowerCase().contains(") values(") || str.toLowerCase().contains(") values (")|| str.toLowerCase().contains(")values(")||str.toLowerCase().contains(")values (")){ String ss = str.substring(0,str.toLowerCase().indexOf("values (")); str = ss.substring(0,ss.indexOf("(")).replaceAll("`", "") + str.substring(str.toLowerCase().indexOf(" values (")); } str +="/r/n"; bWriter.write(str); } bReader.close(); bWriter.close(); }
此部分程序不是很智能,此处只举个例子。
b:这里是通过将一个表的数据导出为一行,这样导出恢复速度快,(sql优化问题),但是注意:当表中的数据行数超过1K时在sql脚本解析中是通不过的,此时应该选择一条记录一行insert语句的形式。(补充点知识:当一行过长时文本编辑器打开的速度会很慢,所以第二种方式也方便在文本编辑器中查看。)
3:利用处理后的sql导入sqlserver数据库。
方法1:直接打开sql文件通过在sqlserver中执行导入。
总结的小知识:
mysql向sqlserver2008兼容
一:脚本兼容问题
1:sqlserver不支持在外键约束中加on delete restrict on update restrict。
2:sqlserver2008不支持drop table if exists XXX。
3:sqlserver2008不支持blob类型,需要改成image或者text类型。
注意,建立数据库时最好用修改的方式添加约束,这样在进行数据库恢复时可以先不建立约束,可以免去约束带来的麻烦和效率问题。
最好将约束整理到最下面。及采用表及约束而不是列及约束。
bitsCN.com
InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.