我想将Oracle 10g数据库中的数据迁移到Postgres数据库。oracle SQL developer有数据迁移选项,但它似乎只用于将非Oracle数据库迁移到oracle。请让我知道其他选择。
发布于 2013-02-13 07:16:00
有一个用Perl编写的专用工具:Ora2Pg。
大多数数据库都提供了从其他数据库导入但不导出到其他数据库的工具。
发布于 2019-12-02 22:42:01
我以前尝试过使用ORA2PG,但它太复杂了,所以我找到了自己的方法从sql developer迁移到postgres。
这里是一步一步的,如果你有任何问题,请告诉我。
如何将数据从ORACLE数据库迁移到POSTGRES数据库!
迁移前要下载的工具: SQL Developer、WINSCP
SQL Developer
导出来自SQL DEVELOPER的文件后
打开WINSCP
WinSCP第1步:登录到您的服务器之前,单击编辑>高级>打开filenames’.
中
现在,使用UTF-8编码的文件应该位于您的服务器上。
开放式putty
在使用Putty登录到您的服务器之前,单击翻译并将接收到的数据假定为使用哪个字符集的数据更改为UTF-8,然后单击数据并将终端类型字符串更改为Putty,然后登录到您的服务器。
使用Putty登录到服务器后,运行以下命令:
区域设置字符映射
此命令将显示服务器的默认编码。
在以下情况下运行该命令:
grep -Rw '/home/pgadmin/data1/1234.csv' -e 'fre' 目录目录data1 =在data1
内的server
此命令将显示文档中的法语单词是否仍丢失。该命令中'/home/pgadmin/data1/1234.csv‘是您的文件在服务器上的位置,’1234.csv‘是CSV文件的名称。如果运行该命令后一切正常,现在我们可以将其放到Postgres数据库中。
在使用命令“psql”进入postgres数据库之后
复制步骤1:确保您已经创建了自己的数据库、模式和表(如果您不知道如何创建,请向下滚动到document).
\Copy joe.data01 FROM ‘home/pgadmin/data1/1234.csv’ DELIMITER ‘,’ CSV HEADER encoding ‘UTF-8’ ;如果该文件在csv文件上已经有列名,则在命令中添加“HEADER”。joe.data01=创建的表的名称home/pgadmin/data1/1234.csv =文件在服务器上的位置
要查看模式是否已复制,只需运行命令select * from joe.data01;
要查看法语单词是否没有丢失,请运行命令select * from joe.data01 where isa = ‘fre’ ;
如何在Postgres上创建数据库:CREATE DATABASE name_of_database ;
CREATE SCHEMA name_of_schema;
create table joe.data01 (ccca CHAR(50) NOT NULL, isa CHAR(70) NOT NULL, co CHAR(150) NOT NULL) ;发布于 2018-05-18 00:10:36
我们最终使用https://github.com/MIT-LCP/oracle-to-postgres中概述的方法将一个相当大的数据库(大约100个模式,有超过1000个表)从Oracle迁移到Postgres。
您可以使用pip install oracle2postgres安装该软件包。欲了解更多信息,请访问:https://pypi.org/project/oracle2postgres/
演示该方法的Jupyter Notebook位于:https://github.com/MIT-LCP/oracle2postgres/blob/master/migration.ipynb。
我们的一般方法是镜像源数据库;在必要时转换数据类型;创建目标数据库;分块复制数据。这是一个有点老生常谈的解决方案,但对我们来说效果很好。
# import the package
import oracle2postgres
# create the logfile
oracle2postgres.create_logfile()
# get source database settings
source_config = oracle2postgres.get_source_config()
# get target database settings
target_config = oracle2postgres.get_target_config()
# get settings for migration
migration_config = oracle2postgres.get_migration_config()
# check the schema exist on the source database
source_engine = oracle2postgres.connect_to_source(source_config)
oracle2postgres.check_schema_exist(source_engine,source_config['schema_list'])
# check for null characters in strings in the source database
# if found, they can be removed as explained in the documentation
oracle2postgres.check_for_nulls(source_engine,source_config['schema_list'])
# create a new database on the target database
target_engine = oracle2postgres.connect_to_target(target_config)
oracle2postgres.create_database(target_config['database'],target_engine)
# create schema on the target database
target_engine = oracle2postgres.connect_to_target(target_config,target_config['database'])
oracle2postgres.create_target_schema(source_config['schema_list'],source_engine,target_engine)
# run the migration
oracle2postgres.migrate(source_config,target_config,migration_config)如果您在重用代码时遇到问题,请随时提出问题,如果是这样的话,我们将尽最大努力提供帮助。
https://stackoverflow.com/questions/14837191
复制相似问题