[英]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:
我的猜测:
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.