Re: [pgsql-fr-generale] Insérer un grand nombre d'entrées (plus ou moins déjà présentes)

From: vincent picavet <vincent(dot)pg(at)picavet(dot)info>
To: Denis Bitouzé <dbitouze(at)wanadoo(dot)fr>
Cc: pgsql-fr-generale(at)postgresql(dot)org
Subject: Re: [pgsql-fr-generale] Insérer un grand nombre d'entrées (plus ou moins déjà présentes)
Date: 2009-06-29 14:53:22
Message-ID: 83978bb40906290753n613d63a5gb4f6b8784c27cfa1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

Salut,

> J'ai un grand nombre d'entrées dans une table de la forme :
>
>  champ_1 | champ_2 |
>  --------+---------+
>  1       |       1 |
>  2       |       1 |
>  3       |       1 |
>  ...
>  n       |       1 |
>
> et je voudrais insérer les entrées (et non pas remplacer au moyen d'un
> update) :
>
>  champ_1 | champ_2 |
>  --------+---------+
>  1       |       2 |
>  2       |       2 |
>  3       |       2 |
>  ...
>  n       |       2 |
>
> Y a-t-il une façon efficace de faire ceci (sans passer par un COPY
> depuis un fichier texte) ?

Quelque chose comme :
INSERT INTO matable SELECT champ_1, 2 FROM matable;
ou
INSERT INTO matable SELECT champ_1, champ_2 + 1 FROM matable;
ou
INSERT INTO matable SELECT champ_1, champ_2 + 1 FROM matable WHERE champ_1 < n;

Ou je n'ai pas compris la question ?

A+
Vincent

In response to

Responses

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Pascal Brognez 2009-06-29 15:03:57 rmll 2009 et Postgresql
Previous Message Denis Bitouzé 2009-06-29 14:41:01 Insérer un grand nombre d'entrées (plus ou moins déjà présentes)