Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/03/2009, 13:07
seyko
 
Fecha de Ingreso: febrero-2007
Mensajes: 1.292
Antigüedad: 17 años, 3 meses
Puntos: 13
Respuesta: copiar registro entero de una tabla a otra

Código:
pruebas=# select * from candidatos
pruebas-# ;
 id |   f_alta   | f_entrevista | entrevistado
----+------------+--------------+--------------
  1 | 2009-02-07 | 2000-01-01   | f
  2 | 2009-02-08 | 2000-01-01   | f
  3 | 2009-02-09 | 2000-01-01   | f
  4 | 2009-02-10 | 2000-01-01   | f
  5 | 2009-02-11 | 2000-01-01   | f
  6 | 2009-02-12 | 2000-01-01   | f
  7 | 2009-02-13 | 2000-01-01   | f
  8 | 2009-02-14 | 2000-01-01   | f
  9 | 2009-02-15 | 2000-01-01   | f
 10 | 2009-02-16 | 2000-01-01   | f
 11 | 2000-01-01 | 2009-02-07   | t
 12 | 2000-01-01 | 2009-02-08   | t
 13 | 2000-01-01 | 2009-02-09   | t
 14 | 2000-01-01 | 2009-02-10   | t
 15 | 2000-01-01 | 2009-02-11   | t
 16 | 2000-01-01 | 2009-02-12   | t
 17 | 2000-01-01 | 2009-02-13   | t
 18 | 2000-01-01 | 2009-02-14   | t
 19 | 2000-01-01 | 2009-02-15   | t
 20 | 2000-01-01 | 2009-02-16   | t
(20 rows)

pruebas=# \d candidatos
                            Table "public.candidatos"
    Column    |  Type   |                        Modifiers
--------------+---------+---------------------------------------------------------
 id           | integer | not null default nextval('candidatos_id_seq'::regclass)
 f_alta       | date    |
 f_entrevista | date    |
 entrevistado | boolean |
Indexes:
    "candidatos_pkey" PRIMARY KEY, btree (id)

pruebas=# \d candidatos_historial
Table "public.candidatos_historial"
    Column    |  Type   | Modifiers
--------------+---------+-----------
 id           | integer |
 f_alta       | date    |
 f_entrevista | date    |
 entrevistado | boolean |
 col_new      | integer |

pruebas=# insert into candidatos_historial select *, 1 from candidatos where id = 10;
INSERT 0 1
pruebas=# select * from candidatos_historial ;
 id |   f_alta   | f_entrevista | entrevistado | col_new
----+------------+--------------+--------------+---------
 10 | 2009-02-16 | 2000-01-01   | f            |       1
Un ejemplo vale más que mil explicaciones

Salu2