简体   繁体   English

将 SQL Server 数据库导出到 sqlite(或 SQL Server Compact)的最佳方式

[英]Best way to export SQL Server database to sqlite (or SQL Server Compact)

Do someone know what would be the best way to transform a big SQL Server database to sqlite or SQL Server compact ?有人知道将大型 SQL Server 数据库转换为 sqlite 或 SQL Server compact 的最佳方法是什么?

SQL Server database should be around 50-70Gb. SQL Server 数据库应该在 50-70Gb 左右。

There are some examples on internet (script schema) but I didn't find anything concluding about data.互联网上有一些例子(脚本模式),但我没有找到任何关于数据的结论。

You can use my Exportsqlce tool to create .sql files in sqlite format from a SQL Server database.您可以使用我的 Exportsqlce 工具从 SQL Server 数据库创建 sqlite 格式的 .sql 文件。 Then run them using sqlite3.exe然后使用 sqlite3.exe 运行它们

Download command line tools from https://github.com/ErikEJ/SqlCeToolbox/releases/tag/3.5.2https://github.com/ErikEJ/SqlCeToolbox/releases/tag/3.5.2下载命令行工具

Export2SQLCE.exe "Data Source=(local);Initial Catalog=Northwind;Integrated Security=True" Northwind.sql sqlite

Good luck!祝你好运!

(I also have SSMS and VS extensions that allow you to do this from a GUI) (我也有 SSMS 和 VS 扩展,允许您从 GUI 执行此操作)

I just did this too with SqlCeToolbox, actually through the SSMS (Sql Server Management Studio) gui — Export my SQL db to SQLite db in SSMS · Issue #327 · ErikEJ_SqlCeToolbox · GitHub .我刚刚也使用 SqlCeToolbox 进行了此操作,实际上是通过 SSMS(Sql Server Management Studio)gui —将我的 SQL db 导出到 SSMS 中的 SQLite db·Issue #327·ErikEJ_SqlCeToolbox·GitHub But it made over 100 .sql script files I had to pipe to sqlite3.但它生成了 100 多个 .sql 脚本文件,我不得不通过管道传输到 sqlite3。

# powershell
dir *.sql | sort name | % { "$_"; cat $_ | sqlite3 newdatabase.db } 

It worked except for 3 parse errors, but I only lost 3 rows.除了 3 个解析错误外它有效,但我只丢失了 3 行。 Somehow directly making the sqlite db failed.不知何故,直接使 sqlite db 失败了。

By the way, searching the script file dump is a create way to search every table.顺便说一句,搜索脚本文件转储是搜索每个表的一种创建方式。 Search Sqlite Database - All Tables and Columns 搜索 Sqlite 数据库 - 所有表和列

sqlite3 database.db .dump | select-string whatever

INSERT INTO mytable VALUES(0,0,0,'whatever',0);

I'm using this software from Code Project:我正在使用 Code Project 中的这个软件:

Convert SQL Server DB to SQLite DB 将 SQL Server 数据库转换为 SQLite 数据库

It connects with your SQL Server and opens Databases to select and select file destination它与您的 SQL Server 连接并打开数据库以选择和选择文件目标将 SQL Server 转换为 SQLite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM