简体   繁体   English

SQL将Microsoft Access sql转储导入Postgres

[英]SQL Importing Microsoft Access sql dump to Postgres

I have a Microsoft Access SQL dump which I am trying to import using psql -f option but getting errors while importing. 我有一个Microsoft Access SQL转储,我试图使用psql -f选项导入,但是在导入时出错。 So is there a way I can convert this SQL dump to support Postgres format. 所以有一种方法可以将这个SQL转储转换为支持Postgres格式。

I have seen some tools which can covert mdb files to respective tables but they are not retaining relationships and other constrains which existing dump has and I want to retain in the import. 我已经看到一些可以将mdb文件隐藏到相应表中的工具,但是它们没有保留现有转储具有的关系和其他约束,并且我想保留在导入中。

# psql -U postgres -f test.sql
psql:test.sql:63: invalid command \Administrators]
psql:test.sql:570: ERROR:  syntax error at or near "Use"
LINE 1: Use [master]
        ^

The dump contains something like below 转储包含如下内容

Use [master]
 GO
 EXEC dbo.sp_dbcmptlevel @dbname=N'test', @new_cmptlevel=90
 GO
 IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
 begin
 EXEC [test].[dbo].[sp_fulltext_database] @action = 'enable'
 end
 GO
 ALTER DATABASE [test] SET ANSI_NULL_DEFAULT OFF

 . . . .


 IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ClassOfService_PBX]') AND parent_object_id = OBJECT_ID(N'[dbo].[ClassOfService]'))
ALTER TABLE [dbo].[ClassOfService]  WITH CHECK ADD  CONSTRAINT [FK_ClassOfService_PBX] FOREIGN KEY([PBX])
REFERENCES [dbo].[PBX] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
. . . 

So is there a way I can import the data. 那么有没有一种方法可以导入数据。

You will want to load the dump back into MS Access, then use tools to extract the data from the live MS Access over ODBC or similar. 您将需要将转储加载回MS Access,然后使用工具通过ODBC或类似工具从实时MS Access中提取数据。 Milen already pointed out that several are listed on the PostgreSQL wiki . Milen已经指出PostgreSQL Wiki上列出几个 There are also generic ETL tools like Talend Studio, Pentaho Kettle, and CloverETL for data migration. 还有一些通用的ETL工具,例如Talend Studio,Pentaho Kettle和CloverETL,用于数据迁移。

If you can only work with a dump, you'll probably have to convert the syntax by hand. 如果只能使用转储,则可能必须手动转换语法。

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

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