Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to migrate sqlite to mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to migrate sqlite to mysql". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1.SQLite export

You can use a variety of tools to export libraries, and I use FireFox's SQLite management plug-in SQLite Manager.

Use the SQLite Manager plug-in to open the (.db .sqlite3) file and select Export. Export the entire library file as a. SQL query statement.

2.SQL statement compatibility modification

In order to ensure the compatibility of SQL statements, it is necessary to modify the unique format of SQLite to MySQL format. Here is my summary of the general rules (the following square brackets should be ignored):

Www.2cto.com

Change ["] to [`]

You can also remove all ["], but you will encounter an error if you have some function names as field names (e.g. Regexp)

It should be noted that some of the default is ["], whose function is not on the field, should not be replaced but should be retained.

Remove all [BEGIN TRANSACTION] [COMMIT] and any (entire) lines that contain [sqlite_sequence]

Change all [autoincrement] to [auto_increment]

Change all ['f'] to ['0'] and all ['t'] to ['1']

Or ['False'] to [' 0'] and ['True'] to [' 1']

Unipue cannot be set in the text field, it needs to be changed to varchar (255)

Note that sqlite is not type-sensitive, so some shaping fields and text fields need to be modified to fit.

The field type that defaults to CURRENT_TIMESTAMP must be TIMESTAMP.

Save the modified file.

3.MySQL Import

Just import it with a handy tool.

This is the end of "how to migrate sqlite to mysql". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report