Re: which function should i invoke to create a table and insert tuples?

From: Thom Brown <thombrown(at)gmail(dot)com>
To: sunpeng <bluevaley(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: which function should i invoke to create a table and insert tuples?
Date: 2010-05-17 14:43:15
Message-ID: AANLkTill5WX4tlS3JYpKkD9wj9Mkt5KnLrGSO5-o3cNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma 2010-05-17 15:00:23 Fwd: Google Alert - postgresql 8.4
Previous Message sunpeng 2010-05-17 14:31:16 which function should i invoke to create a table and insert tuples?