DB2 常用SQL语句
1. 创建从1开始,自增为1的序列:
CREATE SEQUENCE "MySchema"."MySeq" AS INTEGER START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUENO CYCLE CACHE 20 NO ORDER
INSERTINTO t_b ( ID, NAME, AGE )SELECT MySeq.nextVal, NAME, AGEFROM t_a;
INSERTINTO t_b ( ID, NAME, AGE ) VALUES ( MySeq.nextVal,'Lilei',22 ) , ( MySeq.nextVal,'Lucy',18 );
SELECT *FROM ( SELECT ROW_NUMBER() OVER(ORDER BY NAME ASC, AGE DESC) AS row_num, NAME, AGE FROM t_b) tWHERE t.row_num >= 21AND t.row_num <= 30