On 17 May 2010 15:31, sunpeng <bluevaley(at)gmail(dot)com> wrote:
> hi,when i do experiment on postgresql 8.4,i need to create a table and
> insert some tuples,which function should i invoke?
> for example,i want to create a table with "create table test (uid
> int,catcode int)" and insert tuples with "insert into test values(1,1)".
> thanks millions!
>
> peng
>
What is it you're testing?
You can insert many rows into a table by doing something like the following:
CREATE TABLE test
(
test_id serial,
test_num int
test_value int
)
INSERT INTO test (test_num, test_value)
SELECT s.a, ceil(random()*100) FROM generate_series(1,1000) as s(a);
That would just put 1,000 entries into the table, the first column would get
its value from its sequence, the second from the series and the third would
be random.
Regards
Thom