简体   繁体   English

如何从Oracle SQL转储获取数据

[英]How to get data from Oracle SQL dump

I have a .sql file (text file containing SQL statements for creating tables and inserting data) that is apprently dumped from an Oracle database. 我有一个.sql文件(包含用于创建表和插入数据的SQL语句的文本文件),该文件已从Oracle数据库中适当地转储了。

I want the data (or at least some of it) imported into a MySQL database. 我希望将数据(或至少其中一些)导入MySQL数据库。 The normal import doesn't work because of some specific datatypes. 由于某些特定的数据类型,常规导入无法正常工作。

What should I do? 我该怎么办? My guesses: 我的猜测:

  1. Somehow create an Oracle database, import the dump, then make SQL requests to pull the data out. 以某种方式创建一个Oracle数据库,导入转储,然后发出SQL请求以提取数据。 If so, do I have to buy the thing? 如果是这样,我必须买东西吗? And do I have to make a separate virtual machine for the Oracle database? 我是否必须为Oracle数据库制作一个单独的虚拟机?
  2. Find and replace Oracle-specific stuff to something that MySQL understands. 查找特定于Oracle的东西并将其替换为MySQL可以理解的东西。 If so, are there any standard ways to translate things like VARCHAR2 ? 如果是这样,是否有任何标准方法来翻译VARCHAR2东西?

It turns out you can translate Oracle to MySQL. 事实证明,您可以 Oracle 转换为MySQL。 Here is a reference page: Oracle to MySQL Migration - SQLines . 这是参考页:从Oracle到MySQL的迁移-SQLines

In my case I had to translate things like NUMBER(13,0) to BIGINT and NUMBER(12,2) to DECIMAL(12,2) . 就我而言,我必须将NUMBER(13,0)BIGINT并将NUMBER(12,2)DECIMAL(12,2)

What wasn't explicitly stated in the big table (but mentioned lower) was that Oracle syntax specifies units for the size of varchar. 大表中没有明确说明(但在下面提到)是Oracle语法指定了varchar大小的单位。 So I translated VARCHAR2(4000 BYTE) to VARCHAR(4000) . 所以我将VARCHAR2(4000 BYTE)VARCHAR(4000)

In my file the to_timestamp function was used. 在我的文件中,使用了to_timestamp函数。 The table of built-in functions did not say what to do, but I replaced it with str_to_date as the result was written to a DATETIME field. 内置函数表str_to_date要做什么,但我将其替换为str_to_date因为结果被写入了DATETIME字段。

I also had microseconds which were excluded from the to_date reference on SQLines . 我也有微秒,这是从to_date 参考中排除的。 At the end of the day to_timestamp('01-JAN-00 12.00.13.130000000 AM','DD-MON-RR HH.MI.SSXFF AM') becomes str_to_date('01-JAN-00 12.00.13.130000000','%d-%b-%y %h.%i.%s.%f') . 在一天结束时to_timestamp('01-JAN-00 12.00.13.130000000 AM','DD-MON-RR HH.MI.SSXFF AM')变成str_to_date('01-JAN-00 12.00.13.130000000','%d-%b-%y %h.%i.%s.%f')

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

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