MySql教程

Mysql与Oracle的删除修改语法差异示例

本文主要是介绍Mysql与Oracle的删除修改语法差异示例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、修改

        Mysql:   两个表关联

示例1:

UPDATE IOV_CAR_INFO TT
JOIN IOV_CAR_PARTS C ON TT.VIN = C.FRAMENUM 
SET TT.EXTRACT = 0 
WHERE
	TT.EXTRACT = 2

 示例2:

UPDATE  `test_user` u
INNER  JOIN
(SELECT u.id,d.city_id FROM test_department d INNER JOIN `test_user` u on u.dept_id=d.id  WHERE u.enabled=0 and d.enabled=0) t
on t.id=u.id
SET u.city_id=t.city_id
WHERE
u.enabled=0
and u.dept_id is not null;

        Oracle:

        示例1:

UPDATE IOV_CAR_INFO  TT 
SET TT.EXTRACT = 0 
WHERE
	TT.ID IN (
	SELECT
		T.ID 
	FROM
		IOV_CAR_INFO T
		JOIN IOV_CAR_PARTS  C ON T.VIN = C.FRAMENUM 
WHERE
	T.EXTRACT = 2)

二、删除

        Mysql:

示例1:

DELETE T 
FROM
	IOV_LIFECYCLE T
	LEFT JOIN IOV_CAR C ON T.VIN = C.VIN
	LEFT JOIN IOV_DEVICE D ON D.IOV_CAR_ID = C.ID 
WHERE
	D.ID IS NULL

        Oracle:

示例1:

DELETE 
FROM
	IOV_LIFECYCLE TT 
WHERE
	TT.ID IN (
	SELECT
		T.ID 
	FROM
		IOV_LIFECYCLE T
		LEFT JOIN IOV_CAR C ON T.VIN = C.VIN
		LEFT JOIN IOV_DEVICE D ON D.IOV_CAR_ID = C.ID 
WHERE
	D.ID IS NULL)

这篇关于Mysql与Oracle的删除修改语法差异示例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!