在时间戳发生变化的oracle sql中插入100万条记录

问题描述 投票:0回答:1

我需要这样的东西

这实际上会在 5-10 分钟内完成...我需要以 1 天的间隔 (NUMTODSINTERVAL(1, 'day')) 测试分区和不分区的成本差异,但我真的不知道如何在短时间内插入 100 万条记录(插入日期实际上会更改每次插入)。

oracle-sqldeveloper partitioning bulkinsert
1个回答
1
投票

不要使用循环,而是在单个语句中执行它,因为它会更少地写入日志文件:

INSERT INTO "SVIL_FABRICKPSD2"."FBK_PAGOPA_TR_PAYMENT" (
  PAY_PAYMENT_ID, PAY_OWNER_SUBSCRIPTION_ID, PAY_DOCUMENT_ID,
  PAY_IUV_CODE, PAY_AUX_DIGIT, PAY_APPLICATION_CODE,
  PAY_DOCUMENT_AMOUNT, PAY_MAIN_CREDITOR_VIRTUAL_ID, PAY_HAS_SUB_CREDITORS,
  PAY_EXECUTION_DATETIME, PAY_PAYMENT_TOKEN, PAY_DESCRIPTION,
  PAY_TOKEN_EXPIRATION_TIME_MS, PAY_IDEMPOTENCY_KEY, PAY_MODEL,
  PAY_STATUS, PAY_TEMPLATE_DOCUMENT_ID, PAY_CREATED_DATETIME,
  PAY_HAS_SENT_OUTCOME_NOTIFICATION, PAY_RETRY_COUNT
) 
SELECT LEVEL, '3736', '302002011111111115',
       '02002011111111115', '3', '02',
       '0.03', '1', '1',
       TIMESTAMP '2023-05-10 16:32:33.353820500 EUROPE/BERLIN' + NUMTODSINTERVAL(LEVEL, 'DAY'),
       'f49d7add8dec4988817a91065a052d05', 'TARI 2021',
       '1800000', '70000000007_100149bdWO', 'STARTED_FROM_PSP',
       'CREATED', '9fb6ce76-86ce-4f9a-ad0b-151736d82a7a',
       TIMESTAMP '2023-05-10 16:33:01.945286000' + NUMTODSINTERVAL(LEVEL, 'DAY'),
       '0', '0'
FROM   DUAL
CONNECT BY LEVEL <= 1e6;
© www.soinside.com 2019 - 2024. All rights reserved.