Oracleにこの巨大なテーブルがあります:
COMPONENTSTATSID NUMBER(38,0)
COMPONENTTYPEID NUMBER(38,0)
NAME VARCHAR2(200 BYTE)
SERIALNUMBER VARCHAR2(150 BYTE)
WEIGHTKG NUMBER(9,0)
SIZEWEIGHTMILIM NUMBER(6,0)
SIZEWIDTHMILIM NUMBER(6,0)
ZONECAGE VARCHAR2(50 BYTE)
SIZELENGHTMILIM NUMBER(6,0)
SIZEDEPTMILIM NUMBER(6,0)
RAMSLOTS NUMBER
NETWORKINTERFACE VARCHAR2(60 BYTE)
RAMSLOTSPEED VARCHAR2(60 BYTE)
RAMSLOTTYPE VARCHAR2(60 BYTE)
POWERWATT NUMBER(5,0)
OPERATINGTEMPERATUREMIN NUMBER(4,0)
OPERATINGTEMPERATUREMAX NUMBER(4,0)
STORAGETEMPERATUREMIN NUMBER(4,0)
STORAGETEMPERATUREMAX NUMBER(4,0)
DATEFORDECOMISN TIMESTAMP(6)
MANIFACTURECOMPANY VARCHAR2(100 BYTE)
MANIFACTUREWARRANTY VARCHAR2(100 BYTE)
UFORM VARCHAR2(30 BYTE)
STATUS VARCHAR2(30 BYTE)
LOCATION VARCHAR2(30 BYTE)
HEATEMISIONSBTU NUMBER(10,0)
PRODUCTIONENVIRONMENT VARCHAR2(30 BYTE)
STANDARTLIFETIME VARCHAR2(30 BYTE)
OPERATINGHAMIDITYRANGE VARCHAR2(30 BYTE)
BOUGTHDATE TIMESTAMP(6)
OPERATINGSYSTEM CLOB
SUPPORTCONTACT VARCHAR2(100 BYTE)
INTERFACETYPE VARCHAR2(60 BYTE)
TYPE VARCHAR2(30 BYTE)
POWERCAPACITYWATT NUMBER(10,0)
COOLINGCAPACITYBTU NUMBER(8,0)
DATEADDED TIMESTAMP(6)
STORAGECONTROLLER VARCHAR2(60 BYTE)
DATEDEPLOYED TIMESTAMP(6)
DESCRIPTION CLOB
MAXNUMBERPROCESSORS NUMBER(2,0)
CPUCACHESIZE VARCHAR2(30 BYTE)
RAMSIZE VARCHAR2(30 BYTE)
USBPORTS NUMBER(2,0)
CPUCORES NUMBER
RAIDSUPPORT VARCHAR2(30 BYTE)
EXPANSIONSLOTS VARCHAR2(60 BYTE)
DISKBAYS VARCHAR2(60 BYTE)
HOTSWAPCOMPONENTS VARCHAR2(60 BYTE)
NUMBERPORTS NUMBER(38,0)
PORTSPEED VARCHAR2(30 BYTE)
MINAMBIENTTEMP NUMBER(10,4)
MAXAMBIENTTEMP NUMBER(10,4)
DCALLOWEDWEIGHTKG NUMBER(10,4)
DCMAXIMUMWEIGHTKG NUMBER(10,4)
DCALLOWEDPOWERWATT NUMBER(10,4)
DCMAXPOWERWATT NUMBER(10,4)
DCALLOWCOOLINGPOWERBTU NUMBER(10,4)
DCMAXCOOLINGPOWERBTU NUMBER(10,4)
ISPBGPASNUMBER VARCHAR2(30 BYTE)
BANDWIDTHUPLOADMB NUMBER(10,0)
BANDWIDTHDOWNLOADMB NUMBER(10,0)
IPVERSION VARCHAR2(30 BYTE)
ISPIPRANGE VARCHAR2(30 BYTE)
この非常に複雑な SQL クエリを使用して、すべての行をテーブルに選択します。
SELECT a.*
FROM (SELECT b.*, rownum rn
FROM (select y.componentstatsid, y.name, y.status, y.location, y.type, y.powerCapacityWatt, y.coolingCapacityBTU, y.minAmbientTemp, y.maxAmbientTemp,
y.operatingHamidityRange, y.dcAllowedWeightKg, y.dcMaximumWeightKg, y.dcAllowedPowerWatt, y.dcMaxPowerWatt, y.dcAllowCoolingPowerBTU, y.dcMaxCoolingPowerBTU, y.datedeployed, y.dateadded, y.description
FROM component x, componentstats y where x.componentstatsid = y.componentstatsid and y.componenttypeid = 1000
ORDER BY %s %s) b
WHERE rownum <= ?) a
WHERE rn > ?
問題は、componentstatsid = 35 の行を 1 つだけ選択するようにクエリを単純化する方法です。なしorder by
。