Re: which function should i invoke to create a table and insert tuples? - Mailing list pgsql-general

From Thom Brown
Subject Re: which function should i invoke to create a table and insert tuples?
Date
Msg-id AANLkTill5WX4tlS3JYpKkD9wj9Mkt5KnLrGSO5-o3cNQ@mail.gmail.com
Whole thread Raw
In response to which function should i invoke to create a table and insert tuples?  (sunpeng <bluevaley@gmail.com>)
List pgsql-general
On 17 May 2010 15:31, sunpeng <bluevaley@gmail.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

pgsql-general by date:

Previous
From: sunpeng
Date:
Subject: which function should i invoke to create a table and insert tuples?
Next
From: Thom Brown
Date:
Subject: Re: which function should i invoke to create a table and insert tuples?