如何将SQLite3脚本转换为PostgreSQL可以理解的脚本? [英] How to convert SQLite3 script into script that PostgreSQL can understand?

查看:340
本文介绍了如何将SQLite3脚本转换为PostgreSQL可以理解的脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SQLite3数据库。我做了一个数据转储,看起来像这样:

I have a SQLite3 database. I did a data dump which looks something like this:

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE "admin_tools_menu_bookmark" (
    "id" integer NOT NULL PRIMARY KEY,
    "user_id" integer NOT NULL,
    "url" varchar(255) NOT NULL,
    "title" varchar(255) NOT NULL
);
INSERT INTO "admin_tools_menu_bookmark" VALUES(1,2,'/admin/recipes/recipe/','Recipe Management');
INSERT INTO "admin_tools_menu_bookmark" VALUES(2,2,'/admin/recipes/ingredient/','Ingredient Management');
CREATE TABLE "admin_tools_dashboard_preferences" (
    "id" integer NOT NULL PRIMARY KEY,
    "user_id" integer NOT NULL,
    "data" text NOT NULL
);
......

我试图在PostgreSQL PgAdmin III中执行此操作,这给了我很多错误,从 PRAGMA 开始,将datetime字段的'unsigned'字段设置为1(而不是true)和0(而不是false)。

I'm trying to execute this in PostgreSQL PgAdmin III, which gives me many many errors starting with PRAGMA, to 'unsigned' fields to datetime fields to 1 instead of true and 0 instead of false.

是否存在转换此脚本的正确方法?

Is there a proper way to convert this script?

我想将每个表导出为CSV,然后将它们导入到PGDB中,但是我有很多表,这是不可行的。

I thought of exporting each table to CSV then importing them into a PGDB but I have so many tables this isn't an option.

推荐答案

我使用了一个名为Navicat的程序。我导出了每个表,然后将它们导入到新数据库中,这既痛苦又缓慢。

I used a program called Navicat. I exported each table and then imported them into the new database, which was painful and slow.

当我放置SQL时,使用SQLiteman进行的SQL转储并不理想进入PG Admin III。

The SQL dump using SQLiteman just didn't bode well when I put the SQL into PG Admin III.

这篇关于如何将SQLite3脚本转换为PostgreSQL可以理解的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆