druid oracle sql语句转mysql
时间: 2023-07-12 20:46:39 浏览: 196
Oracle Sql语句转换成Mysql Sql语句
3星 · 编辑精心推荐
很抱歉,Druid不能直接将Oracle SQL语句转换为MySQL语句,因为Oracle和MySQL的语法有很大的区别。但是,你可以手动将Oracle SQL语句转换为MySQL语句,或者使用一些第三方工具进行转换。
以下是一些常见的Oracle SQL语句与MySQL语句的对比:
1. 创建表:
Oracle SQL语句:
```
CREATE TABLE employees (
employee_id NUMBER(6),
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
hire_date DATE,
job_id VARCHAR2(10),
salary NUMBER(8,2),
commission_pct NUMBER(2,2),
manager_id NUMBER(6),
department_id NUMBER(4)
);
```
MySQL语句:
```
CREATE TABLE employees (
employee_id INT(6),
first_name VARCHAR(20),
last_name VARCHAR(25),
email VARCHAR(25),
hire_date DATE,
job_id VARCHAR(10),
salary DECIMAL(8,2),
commission_pct DECIMAL(2,2),
manager_id INT(6),
department_id INT(4)
);
```
2. 插入数据:
Oracle SQL语句:
```
INSERT INTO employees (employee_id, first_name, last_name, email, hire_date, job_id, salary, commission_pct, manager_id, department_id)
VALUES (100, 'Steven', 'King', 'steven.king@example.com', '17-JUN-87', 'AD_PRES', 24000, NULL, NULL, 90);
```
MySQL语句:
```
INSERT INTO employees (employee_id, first_name, last_name, email, hire_date, job_id, salary, commission_pct, manager_id, department_id)
VALUES (100, 'Steven', 'King', 'steven.king@example.com', '1987-06-17', 'AD_PRES', 24000, NULL, NULL, 90);
```
3. 查询数据:
Oracle SQL语句:
```
SELECT employee_id, first_name, last_name, email, hire_date, job_id, salary, commission_pct, manager_id, department_id
FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC;
```
MySQL语句:
```
SELECT employee_id, first_name, last_name, email, hire_date, job_id, salary, commission_pct, manager_id, department_id
FROM employees
WHERE department_id = 90
ORDER BY hire_date DESC;
```
需要注意的是,Oracle和MySQL的数据类型有很大的区别,因此在进行数据类型转换时需要注意精度和类型的匹配问题。
阅读全文