Skip site navigation (1) Skip section navigation (2)

Partial table copy?

From: Mark Thomas <thomas(at)pbegames(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Partial table copy?
Date: 2002-05-08 15:21:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I have a table that was created like this:


CREATE TABLE "players"
     "pid" integer PRIMARY KEY DEFAULT nextval('id_seq') NOT NULL,
     "pname" text,
     "value" integer,

For testing purposes I'd like to create some test data:

COPY "players" FROM stdin;
1       Bill    8
2       Frank   100

This works, but leaves my sequence out of sync with my actual data. What 
I'd really like is:

COPY "players" FROM stdin;
nextval('id_seq')       Bill    8
nextval('id_seq')       Frank   100

Obviously that won't work. I guess I can do:

INSERT INTO "players" (pname, value) VALUES ('Bill', 8);
INSERT INTO "players" (pname, value) VALUES ('Frank', 100);

But that seems less intuitive. Is there a better way?

Mark Thomas
thomas(at)pbegames(dot)com ---->
Play by Electron Games -> Free Trial Games


pgsql-novice by date

Next:From: Leandro FanzoneDate: 2002-05-08 16:21:09
Subject: Too many clients
Previous:From: Joshua b. JoreDate: 2002-05-08 14:08:19
Subject: Re: Appending values non-destructively

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group