From: | Marcelo Fernández <fernandezm22(at)yahoo(dot)com(dot)ar> |
---|---|
To: | Gustavo Rosso <grosso(at)sadaic(dot)org(dot)ar> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: serial |
Date: | 2008-12-04 16:11:49 |
Message-ID: | 49380145.1090207@yahoo.com.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Gustavo Rosso escribió:
> Hola.
> Estoy migrando base de datos informix a postgres.
> Tengo una tabla con un campo serial, como deberia definirla en postgres
> para que sea de tipo auto_incremento?
Hola Gustavo, por ejemplo así:
CREATE TABLE cliente (
id SERIAL PRIMARY KEY,
apellido VARCHAR(30),
nombre VARCHAR(30)
);
http://www.postgresql.org/docs/8.3/interactive/datatype-numeric.html#DATATYPE-SERIAL
> Como debo indicar la instruccion insert?
De la misma URL:
"To insert the next value of the sequence into the serial column,
specify that the serial column should be assigned its default value.
This can be done either by excluding the column from the list of columns
in the INSERT statement, or through the use of the DEFAULT key word."
Ejemplo:
INSERT INTO CLIENTE (apellido, nombre) VALUES ('Rosso','Gustavo');
Saludos,
Marcelo
--
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA
E-Mail: fernandezm22(at)yahoo(dot)com(dot)ar
Jabber ID: fernandezm22(at)jabber(dot)org
Public Key ID: 5C990A6C 111C3661
Blog: http://marcelosoft.blogspot.com
From | Date | Subject | |
---|---|---|---|
Next Message | Edwin Quijada | 2008-12-04 16:16:09 | RE: serial |
Previous Message | Edwin Quijada | 2008-12-04 16:06:31 | Re: [pgsql-es-ayuda] traduccion |