npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

db2-random-data

v1.0.0

Published

这个工具读取一个表名和数据量列表,向指定 schema 下的表插入随机数据。

Readme

Db2 12.1.2 random test-data inserter

这个工具读取一个表名和数据量列表,向指定 schema 下的表插入随机数据。

直接执行

列表文件格式:

CUSTOMER,100
ORDERS,200
PRODUCT,50

执行前准备好 Db2 CLP 和数据库连接环境,然后传入 schema 和列表文件:

chmod +x random_insert.sh
./random_insert.sh APP list.txt

通过 npm 全局安装后也可以执行:

db2-random-data APP list.txt

脚本安装过程一次、设置 schema 一次、逐行插入,最后提交。

不需要在 Docker 容器内执行。只要运行脚本的机器具有 Db2 CLP,它可以连接本机 或远程 DB2。Docker 只是开发阶段可选的测试数据库。

Implemented mapping

| Db2 type | Generated value | | --- | --- | | CHAR, CHARACTER, VARCHAR | random ASCII digit string, bounded by SYSCAT.COLUMNS.LENGTH | | DECIMAL, NUMERIC | random value derived from precision (LENGTH) and SCALE, with an overflow safety margin | | integer and floating numeric types | random value within a conservative type-safe range | | DATE | CURRENT DATE | | TIMESTAMP | CURRENT TIMESTAMP | | BLOB | fixed X'ABCD1234' bytes | | any other type | NULL |

Identity and generated columns are omitted from the insert list. Inserts use a single recursive-CTE INSERT ... SELECT except for the rare table containing only generated columns.

Expected limitations

This is type-aware rather than business-aware. Foreign keys, unique keys, check constraints, triggers, row/column access control, and unsupported NOT NULL columns can still reject the insert. Very large DATACOUNT values also create a large transaction; commit batching is intentionally not hidden inside the procedure.

SQL PL 已依据 IBM Db2 12.1 文档检查;当前版本没有在真实 Db2 12.1.2 实例中 执行过,首次在目标环境运行前应先对测试表进行一次 smoke test。