问题
I'm a newbie at pgAdmin3 and I want to populate a database in pgAdmin3 with numbers 1-1000. How can I go about doing this? Currently, I have a database created called MyDatabase (with nothing in it). Every row should correspond to its numerical value (row 1 should contain 1, row 2 should contain 2, etc...)
回答1:
You don't populate a "database" - you populate a table:
This can be done quite easily using generate_series()
Assuming you have a table called my_table
with a column named id
you can do:
insert into my_table (id)
select i
from generate_series(1,1000) i
来源:https://stackoverflow.com/questions/44786031/populate-postgres-database-with-numbers-1-1000