Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 459641337B55 for ; Fri, 24 Sep 2010 06:44:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 05440-08 for ; Fri, 24 Sep 2010 09:44:02 +0000 (UTC) X-Greylist: delayed 00:06:39.060263 by SQLgrey-1.7.6 Received: from web27908.mail.ukl.yahoo.com (web27908.mail.ukl.yahoo.com [217.146.182.58]) by mail.postgresql.org (Postfix) with SMTP id CF1B51336FA7 for ; Fri, 24 Sep 2010 06:44:01 -0300 (ADT) Received: (qmail 8544 invoked by uid 60001); 24 Sep 2010 09:37:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1285321041; bh=rw0nDyaKm7uCket9532fZWPY3XStAa8y+oUcXibl720=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=A4NhtPtFrMOkXpn6/X6En0RpeWzX/BuFO957NavkNuCNl1c8W+SRa7e3J07JoUH+ldWPwJi1TSblBDwStLmXm5L0DAZsd9ViHJHePjTSprGI3zU03LN0naWv0171/to7g6rXvu7mnF9XyOEpobfpBar8dOvYioLaLRsH7V2Ieik= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=AvmkcRNgzMmZTDpkIdsZv1qEtP+ntRKvsc8gPdVj51CB2vSnbW3NZ8OTqDPSaobvVlpL2RTPcAgVWqErNz6hdtE8j/GCfFtnRvce/arlJDn2gOvfNo7iFc6l8Sd4sPzVARYUFFlN0AT/whm0/G3JVbeX9Y0C4NjaCLTti1etM6U=; Message-ID: <474252.7907.qm@web27908.mail.ukl.yahoo.com> X-YMail-OSG: TTemkk0VM1njXuNkuAUa_erzuIQ7uK0ytKM0pFUg1wGVsbP FLmzZgQ2xPhBQ21fjWtcFQEJnc2K87zZ1P.DfZL6yHNlVhIqfi_fk.pQT8pc WlGogCWdBtyoh3Uox9sXwLNKuV2MO1qQa_glAFa9DqFUBaIke7Z2GGjR0DA9 OlInpQfpCfJ7DPxn7VNTiq6abmWMwzncTXs6mQJbA3tnixfEcx9bn6iwZaIP NY6motHcrmIRg3bOtGShnxDyTm.R1rEJ5PFLyA0Vg5ck6xD2VPRJvVQ8- Received: from [172.16.10.29] by web27908.mail.ukl.yahoo.com via HTTP; Fri, 24 Sep 2010 09:37:21 GMT X-Mailer: YahooMailClassic/11.4.9 YahooMailWebService/0.8.105.279950 Date: Fri, 24 Sep 2010 09:37:21 +0000 (GMT) From: James Kitambara Subject: Re: insert into help To: Guillaume Lelarge Cc: pgsql-sql In-Reply-To: <4C99B1B8.6040607@lelarge.info> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-917738869-1285321041=:7907" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201009/97 X-Sequence-Number: 34628 --0-917738869-1285321041=:7907 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hello Guillaume Lelarge ! I suggest you try the following question: RE-CREATE YOUR TABLES AS FOLLOW: CREATE SEQUENCE table1_id_seq =A0 INCREMENT 1 =A0 MINVALUE 1 =A0 MAXVALUE 10000000 =A0 START 1 =A0 CACHE 1; CREATE TABLE TABLE1 ( =A0=A0=A0 ID INTEGER NOT NULL DEFAULT nextval('table1_id_seq'::regclass) =A0=A0=A0=A0=A0 , NAME VARCHAR(200) NOT NULL ); CREATE TABLE TABLE2 ( =A0=A0=A0=A0=A0=A0=A0 NAME VARCHAR(200) NOT NULL ); ------------------------INSERTING THE DATA------------------------------ INSERT INTO TABLE1 (NAME) SELECT NAME FROM TABLE2; Note:=A0 The ID in Table1 will be generated automaticale because of=20 =A0=A0=A0=A0=A0=A0 DEFAULT nextval('table1_id_seq'::regclass) =A0 James Kitambara Computer System Analyst and Programmer Bank of Tanzania, P.O. Box 2939, Mobile : +255 71 3307632, Dar es Salaam, Tanzania. = =A0 --- On Wed, 22/9/10, Guillaume Lelarge wrote: From: Guillaume Lelarge Subject: Re: [SQL] insert into help To: "Nicholas I" Cc: pgsql-sql@postgresql.org Date: Wednesday, 22 September, 2010, 8:35 Le 22/09/2010 09:32, Nicholas I a =E9crit : > Hi, >=20 >=A0 i have two tables, > --------------------------------------------------------------- > *table1 >=20 > id type serial, name varchar;* > *-------------------------------------------------------------- > table 2 >=20 > name varchar;* > --------------------------------------------------------------- >=20 > i want to insert the values of table 2 into table 1, with automatic id's. >=20 > insert into table1(select * from table2); >=20 > is not working, how can i append the data to table 1 with auto incremente= d > or nextval. >=20 INSERT INTO table1 (name) SELECT name FROM table2; --=20 Guillaume http://www.postgresql.fr http://dalibo.com --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql =0A=0A=0A --0-917738869-1285321041=:7907 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable

Hello Guillaume Lelarge !

I sugges= t you try the following question:

RE-CREATE YOUR TABLES AS FOLLOW:


CREATE SEQUENCE table1_id_seq
  INCREMENT 1
 = MINVALUE 1
  MAXVALUE 10000000
  START 1
  CACHE 1= ;

CREATE TABLE TABLE1 (
    ID INTEGER NOT NULL DE= FAULT nextval('table1_id_seq'::regclass)
      = , NAME VARCHAR(200) NOT NULL
);



CREATE TABLE TABLE2 (
=         NAME VARCHAR(200) NOT NULL
);=



------------------------INSERTING THE DATA-----------------= -------------

INSERT INTO TABLE1 (NAME) SELECT NAME FROM TABLE2;
=
Note:  The ID in Table1 will be generated automaticale because of =
       DEFAULT nextval('table1_id_seq'::regclass)


 

James Kitambara
Compu= ter System Analyst and Programmer
Bank of Tanzania,
<= /div>
P.O. Box 2939,
Mobile : +255 71 = 3307632,
Dar es Salaam,
Tanzania.
 

--- On Wed, 22/9/1= 0, Guillaume Lelarge <guillaume@lelarge.info> wrote:

From: Guillaume Lelarge <guillaume@lelarge.info>
Subjec= t: Re: [SQL] insert into help
To: "Nicholas I" <nicholas.domnic.i@gma= il.com>
Cc: pgsql-sql@postgresql.org
Date: Wednesday, 22 September= , 2010, 8:35

Le 22/09/2010 09:32, Nicholas = I a =E9crit :
> Hi,
>
>  i have two tables,
>= ---------------------------------------------------------------
> *t= able1
>
> id type serial, name varchar;*
> *------------= --------------------------------------------------
> table 2
> =
> name varchar;*
> -------------------------------------------= --------------------
>
> i want to insert the values of table = 2 into table 1, with automatic id's.
>
> insert into table1(se= lect * from table2);
>
> is not working, how can i append the = data to table 1 with auto incremented
> or nextval.
>

INSERT INTO table1 (name) SELECT name FROM table2;


-- <= br>Guillaume
htt= p://www.postgresql.fr
http://dalibo.com

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to you= r subscription:
http://www.postgresql.org/mailpref/pgsql-sql

=0A=0A=0A=0A --0-917738869-1285321041=:7907--