1.查看存储过程:打开Procedures菜单树
2.往数据库里插入大量id自增的数据:
CREATE OR REPLACE PROCEDURE insert_fake_full_order (p_count IN NUMBER) AS
v_max_id NUMBER;
BEGIN
FOR i IN 1..p_count LOOP
DBMS_OUTPUT.PUT_LINE('正在插入订单: ' || i);
SELECT MAX(id) + 1 INTO v_max_id FROM xxx.V_xxx;
insert into xxx.V_xxx (ID, CODE, ORDER_TYPE)
values ( v_max_id+i, 'TT'||i, 'M';
END LOOP;
DBMS_OUTPUT.PUT_LINE('插入完成');
COMMIT;
END;
3.另一种自增方法
CREATE OR REPLACE PROCEDURE insert_fake_Order_Add (p_count IN NUMBER) AS
v_max_id NUMBER;
v_current_id NUMBER;
BEGIN
SELECT MAX(id) + 1 INTO v_max_id FROM xx.v_xxxd;
v_current_id := NVL(v_max_id, 0) + 1;
FOR i IN 1..p_count LOOP
BEGIN
DBMS_OUTPUT.PUT_LINE('正在插入Order_Add: ' || i);
insert into xx.v_xxx (ID, ORDER_ID)
values (v_current_id, v_current_id+1);
v_current_id := v_current_id + 1;
END;
END LOOP;
COMMIT;
DBMS_OUTPUT.PUT_LINE('插入完成');
END;