那些臭名昭著的sql

简介: 两个或多个表关联,没写where条件,大量的笛卡尔值,严重时会导致数据库有问题。 select * from a, b left join c on b.id = c.id left join d on c.id = d.id 多表关联查询,where条件使用各种函数,导致索引无效。
  • 两个或多个表关联,没写where条件,大量的笛卡尔值,严重时会导致数据库有问题。
select * from a, b left join c on b.id = c.id left join d on c.id = d.id
  • 多表关联查询,where条件使用各种函数,导致索引无效。数据量如果打起来以后会导致查询像蜗牛一样。
select 
trim(d.circuitid) as circuitid,
trim(d.Code) as Code,
trim(d.Oldname) as Oldname,
trim(d.Circuittype) as Circuittype,
trim(d.Status) as Status,
trim(d.customerid) as acustomerid,
trim(d.alinkman) as alinkman,
trim(d.zlinkman) as zlinkman,
trim(d.alinkmantel) as alinkmantel,
trim(d.zlinkmantel) as zlinkmantel,
trim(d.busi_no) as busi_no,
trim(d.service_serial) as service_serial,
trim(a.region_ID) as regionid ,
2 as SORTID
from test1 a,test2 b,test3 c,test4 d 
where trim(a.room_id)=trim(b.roomID) and trim(b.neid)=trim(c.neid) and (trim(c.portid)=trim(d.aendname) or trim(c.portid)=trim(d.zendname))

 

相关文章
|
3月前
|
SQL 数据库 索引
八、SQL-Limite
八、SQL-Limite
24 0
|
SQL 数据挖掘 Python
sql8&10&11&12,3+1
sql8&10&11&12,3+1
sql8&10&11&12,3+1
|
SQL 网络协议 NoSQL
sql审核
sql审核
336 0
|
SQL 数据库
了解SQL
了解SQL
93 0
|
存储 SQL NoSQL
SQL必知必会(一)
对于我们而言,数据库是一个以某种有组织的方式存储的数据集合。最简单的办法就是将数据库想象成一个文件柜。这个文件柜是一个存放数据的物理位置,不管数据是什么,也不管数据是如何组织的。 数据库(DataBase) 保存有组织数据的容器(通常为一个或一组文件)
|
关系型数据库
xttdbopen.sql
connect / as sysdba; alter database mount;alter database open; exit
735 0
|
SQL 关系型数据库 PostgreSQL