Recently, doing and a top story called chat for ten years, he says, at the time of development projects, often met the needs of different situations, with different type of database is one of our projects with changeless should change measures, at the bottom will be compatible with a variety of database allows us to develop different types of projects with ease, if cooperate with rapid framework supports, That was the icing on the cake. His projects or frameworks, using modules from Microsoft’s Enterprise Library, tend to support multiple databases, and provide a very convenient, fast, unified approach to developing different types of projects. General general databases include MS Server, Oracle, MySQL, PostgreSQL, SQLite, DB2, domestic dameng and other databases

This article mainly introduces how to implement from MS SQLServer to Mysql database, and adds the underlying solution for different database types. The MySQL database learning video is attached at the end of the article

1, SQLServer database export to MySQL if we have based on SQLServer development, and have a lot of basic database data, then we can use SQLServer export to MySQL database, this is a common way of development, After all, based on SQLServer database development will be faster.

SQL Server Management Studio is the Management tool of SQL Server database. The Mysql database management tool is recommended to use Navicat, which is a very powerful management tool.

First we use Navicat to create a blank Mysql database for SQL Server data export needs.

For example, we create a MVCWebMisTest database with the same name as the SQL Server database, and set its character set to default or UTF8 encoding, as shown below.

Then use SQL Server Management Studio to directly export data, select [Task] [Export data], as shown below.

Then select the imported data source and target in the pop-up database. The interface for selecting imported data source is shown as follows.

Then select the Mysql driver in the target and fill in the corresponding information, as shown in the following screen.

In the next step, select the table information to export.

Unfortunately, the export operation to manipulate the database in this way will not succeed.

SQLServer Management Studio SQLServer Management Studio SQLServer Management Studio SQLServer Management Studio SQLServer Management Studio SQLServer Management Studio It also has data transfer (import and export) functions.

We right click on the database we just built to bring up the corresponding [data transfer] function, and then set the source and target of the data, as shown below.

Perform data transfer operations, complete smoothly, very powerful and convenient, and without any errors. The following page is displayed.

Check the imported tables and data from the database. No problem.

So if we need to deploy to the server, we need to transfer the current Mysql database (or restore) to the server Mysql database, generally speaking, we use Mysql Navicat management tool can achieve data export SQL file, Then use the reverse operation inside the server to restore the database successfully.

The SQL file is dumped successfully, as shown in the following dialog box:

On the server, we can restore the Mysql database using Navicat running SQL files.

The result of the run is shown below.

Of course, sometimes there will be some table dependency reference situation, I do not know whether Navicat version of the problem, but if there is a problem, as long as it is not the coding problem, it is easy to solve, open SQL file to create the table order adjustment can be, I have encountered this extreme situation, Move some dependency tables to the front to import data smoothly.

4, at the bottom of the Mysql database supports the underlying support for multiple database, we develop different types of projects has a very important role in supporting, we don’t know the customer specific environment will choose that kind of database, if we extend the different database is very convenient and quick, will no doubt provide us with very good control and confidence.

After using Microsoft Enterprise Library as our underlying database access module, the database access object of this Enterprise Library will be used uniformly for various database access operations. The operation is very consistent. In order to further encapsulate some operations such as routine add, delete, change and check of different databases, To simplify the code, we can define a data access operation base class for each different database to handle some of the differences between the different databases, but they still have a common data access base class.

Using different databases, we need to generate for different database access layer processing, such as table for SQLServer data to generate the relevant data access layer DALSQL, which places the contents of each table object, but because of the use of related inheritance class processing and based on the database code generation, the need to adjust the code is very few.

We have prepared different database implementations for different databases, but only special interface calls, general general add, delete, change, search, paging and other common interfaces, all by the base class interface can be implemented.

For the permission management system, which is a common framework base module, the support of multiple databases is very necessary, and its database access layer is shown below.

Different database access layer implementations are also similar, generally can use code generation tools for rapid generation, add a custom interface implementation.

For different database support, directly copy the past, change the database implementation layer namespace and access layer base class can be, if there is a custom SQL script on the difference, can be modified appropriately. Generally from one kind of database support to another kind of database support, nothing more than copy the past, adjust it, very convenient and fast, this is the charm and efficiency of the overall framework support.

After this integration of the underlying layers of multiple database support, the overall data access architecture is designed as follows.

With this underlying support, we can selectively keep one database configuration information when selecting different databases in the configuration file. The following lists the configuration information supported by various databases. You only need to reserve one configuration information.

Recently, I have sorted out some Mysql database materials and shared them with you. Please kindly forward this article + follow me, and then add the small assistant VX: Xuanwo008 to our products

【 database 】4 sets of Mysql, from small white to big god, database query optimization, large distributed cluster, database operation and maintenance video course 【 database 】Mysql from small white to big god

MySQL Advanced Large distributed cluster, master/slave replication, load balancing, database middleware video course

MySQL database query optimization

Please kindly forward this article + follow me and add the small assistant VX: Xuanwo008 to be ready