mysql - 将oracle sql脚本转换为mysql

标签 mysql oracle phpmyadmin

嗨,我正在寻找将我的 oracle sql 脚本的一部分转换为 mysql 脚本。

我要转换的部分如下:

create table inspection
(property_no number(5) not null references prop_for_rent(property_no),
staff_no number(5) not null references staff(staff_no),
inspect_date date,
comments varchar2(50),
primary key(property_no,staff_no,inspect_date))

我已经开始转换,只是主键有困难,这会引发错误#1062 - 插入数据库时​​主键的重复条目。图片链接如下:

/image/VfVW9.png

最佳答案

我认为您会发现插入的 inspect_date 列的值为零日期 '0000-00-00',这是因为INSERT 语句 '12-JUN-2010' 不是 MySQL 中日期值的有效格式。

在 MySQL 中,我们可以这样做:

... VALUES(1001,201,STR_TO_DATE('12-JUN-2010','%d-%b-%Y'),'No  problems')
                    ^^^^^^^^^^^^             ^^^^^^^^^^^^

或者这个:

... VALUES(1001,201,'2010-06-12','No  problems')
                    ^^^^^^^^^^^^

关于mysql - 将oracle sql脚本转换为mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47838355/

相关文章:

mysql - 以日历季度为列分组

php - 将数据输出为 Excel 文件

mysql - 条件 str_to_date() 如果格式是一种类型,否则不执行任何操作

sql - 近4季度数据

java - 如何使用mybatis调用oracle存储过程(基于注解。)

sql - 如何将独立字符的实例与字符串字段分开

php - 多个查询在一个php文件中使用前一个查询的结果集

MySQL相似表的索引使用不一致: 'Using index' and 'Using where; Using index'

mysql - 如何在 phpmyadmin 中将 "Relational display column"设置为默认值

mysql - phpMyAdmin 在登录远程时出现错误。#2002 无法登录 MySQL 服务器