易截截图软件、单文件、免安装、纯绿色、仅160KB

oracle 多表删除 同时删除多表中关联数据

oracle 多表删除 同时删除多表中关联数据
2009-04-27 14:40
1、从数据表t1中把那些id值在数据表t2里有匹配的记录全删除掉
DELETE t1 from t1,t2 WHERE t1.id=t2.id    或DELETE from t1 USING t1,t2 WHERE t1.id=t2.id
2、从数据表t1里在数据表t2里没有匹配的记录查找出来并删除掉
DELETE t1 from t1 LEFT JOIN T2 ON t1.id=t2.id WHERE t2.id IS NULL 或
DELETE from t1,USING t1 LEFT JOIN T2 ON t1.id=t2.id WHERE t2.id IS NULL
3、从两个表中找出相同记录的数据并把两个表中的数据都删除掉
DELETE t1,t2 from t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t1.id=25
注意此处的delete t1,t2 from 中的t1,t2不能是别名
如:delete t1,t2 from table_name as t1 left join table2_name as t2 on t1.id=t2.id where table_name.id=25 在数据里面执行是错误的(MYSQL 版本不小于5.0在5.0中是可以的)
上述语句改写成
delete table_name,table2_name from table_name as t1 left join table2_name as t2 on t1.id=t2.id where table_name.id=25 在数据里面执行是错误的(MYSQL 版本小于5.0在5.0中是可以的)
多表连接查询很相似,不详加说明了


相关文档:

Oracle学习总结

Oracle:一个数据库有多个用户,一个用户拥有一组数据库对象,这个用户我们俗称为方案,
      通常一个业务系统对应一个数据库用户。
★Oracle安装成功后会自动创建十来个系统界别的账户。默认情况下这些账户中只有四个可用,其它的帐号都被设置成了锁定或是设置为过   期状态,这四个帐户就 ......

ARCSDE for Oracle 数据存储形式为st_geometry

SELECT sde.st_area(zone) from sde.test1 ORDER BY name;//
SELECT shape from schools ORDER BY name;
SELECT objectid, sde.st_astext(SDE.ST_POINTfromSHAPE(shape,0)) AS points from schools;
SELECT name, sde.st_x (zone) "The X coordinate" from test ; //正确执行
SELECT name, sde.st_x (shape)  "The ......

oracle DBTIMEZONE时区调整

select dbtimezone from dual ;  --查看数据库时区
select sessiontimezone from dual ;  --查看会话时区
1.select u.name || '.' || o.name || '.' || c.name TSLTZcolumn
       from sys.obj$ o, sys.col$ c, sys.user$ u
      &nbs ......

Upgrade Oracle 9i RAC to Oracle 10g RAC

Upgrade Oracle 9i RAC to Oracle 10g RAC
by Vincent Chan
This article provides the procedures for converting Oracle 9i (9.2.0.4) RAC to Oracle 10g (10.2.0.1) RAC on Red Hat Enterprise Linux 3 (RHEL3).
Oracle Database 10g and Oracle Real Application Cluster (RAC) 10g itself, boast many new and ex ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号