标签: postgresql scripting pgadmin
我有一个名为id的单个表,如下所示。我需要用数字1-1000填充表格,我怎么能用脚本编写呢?
答案 0 :(得分:1)
使用generate_series:
--Without column declaration INSERT INTO "MyTable" SELECT generate_series(1, 1000); --With column declaration INSERT INTO "MyTable"(id) SELECT generate_series(1, 1000);