From: | Andy Colson <andy(at)squeakycode(dot)net> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Strategy for Primary Key Generation When Populating Table |
Date: | 2012-02-09 17:10:18 |
Message-ID: | 4F33FDFA.4010403@squeakycode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2/9/2012 10:49 AM, Rich Shepard wrote:
> I have a lot of data currently in .pdf files. I can extract the relevant
> data to plain text and format it to create a large text file of "INSERT
> INTO
> ..." rows. I need a unique ID for each row and there are no columns that
> would make a natural key so the serial data type would be appropriate.
>
> When I prepare the text file I can start each row with the delimiter (',')
> to indicate there's a table column preceding. If I define the primary key
> as serial type on that first position in the file, will postgres
> automagically fill it in as each row is read into the table?
>
> If not, or if there's a better way of approaching this task, please clue
> me in to that.
>
> TIA,
>
> Rich
>
>
>
If you create a serial column, dont put the column name or a value into
your insert statement.
create table junk (id serial, stuff text);
insert into junk(stuff) values ('my stuff');
or, and I've never done this, I think you can use the default keyword:
insert into junk(id, stuff) values (default, 'my stuff');
-Andy
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2012-02-09 17:18:44 | Re: Strategy for Primary Key Generation When Populating Table |
Previous Message | Rich Shepard | 2012-02-09 17:08:57 | Re: Strategy for Primary Key Generation When Populating Table |