DB&SQL备忘

DB2最佳分页语句

SELECT * FROM (
        SELECT inner2_.*, ROWNUMBER() OVER(ORDER BY ORDER OF inner2_) AS rownumber_ FROM 
                (SELECT * FROM IMS.IMS_PRODUCT WHERE status='G' FETCH FIRST 300 ROWS ONLY) 
                AS inner2_
        ) AS inner1_ 
WHERE rownumber_>1 ORDER BY rownumber_

 

DB2简单离线备份命令

db2 backup db learning to e:    
备份成功。此备份映像的时间戳记是:20150316104830

db2 restore db learning from E:
C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 restore db learning from E:
SQL2539W  警告!正在复原至与备份映像数据库相同的现有数据库。数据库文件将被删除。

想要继续吗?(y/n) y
DB20000I  RESTORE DATABASE 命令成功完成。

 

INSERT INTO SELECT 语句

insert into ims.product(OEM_ID, MACHINE, MODEL, PSEDUO_TYPE, PSEDUO_MODEL, MODEL_SYNONYMS, STATUS, CREATED_TIME, LAST_UPDATE_TIME, LAST_UPDATE_BY) 
        select OEM_ID, MACHINE, MODEL, PSEDUO_TYPE, PSEDUO_MODEL, MODEL_SYNONYMS, STATUS, CREATED_TIME, LAST_UPDATE_TIME, LAST_UPDATE_BY from ims.ims_product

 

你可能感兴趣的:(DB&SQL备忘)