Re: [Pgsql-ayuda] Sybase/PostgreSQL

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: sandrigo lezcano <psql(at)msa(dot)com(dot)py>
Cc: Pgsql-ayuda <Pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx>
Subject: Re: [Pgsql-ayuda] Sybase/PostgreSQL
Date: 2003-05-27 23:47:43
Message-ID: 20030527234743.GA4440@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On Tue, May 27, 2003 at 07:34:48PM -0500, sandrigo lezcano wrote:

Sandrigo,

(Ojo, la lista doc-postgresql-es tiene que ver con traducciones de los
manuales, no con soporte...)

> en Sybase se guardan los graficos en campos tipo "long binary"
> en PostgreSQL podria ser "bigint" ?????

BYTEA.

> en Sybase se guardan los un campo tipo "integer" se define de como "not
> null default autoincrement"
> en PostgreSQL "CREO" podria ser ????? "serial" ????

El integer sigue siendo INTEGER; el campo con atributo autoincrement
podrias pasarlo a SERIAL.

> /*-- codigo en Sybase ----------------------------- */
> create table imagenes
> (
> numero_interno integer not null default
> autoincrement,
> legajo integer not null
> check (legajo >= 1),
> tipo_imagen char not null
> check (tipo_imagen in ('1','2','3','9')),
> imagen long binary,
> observacion varchar(256),
> fecha date not null default 'today()',
> primary key (numero_interno)
> )

Hm.. Creo que tendria que ser

create table imagenes (
numero_interno serial primary key,
legajo integer not null check (legajo >= 1),
tipo_imagen "char" not null check (tipo_imagen in
('1', '2', '3', '9')),
imagen bytea,
observacion varchar(256),
fecha date not null default current_timestamp::date
)

cuando insertas, omites el numero_interno:
insert into imagenes (legajo, tipo_imagen, imagen, observacion, fecha)
values (blah blah)

Esto le asigna un valor apropiado a numero_interno con el cual no
deberias jugar mucho, sobre todo porque es la llave primaria.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La vida es para el que se aventura"

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2003-05-28 00:20:30 Re: [Pgsql-ayuda] RE:Sybase/PostgreSQL("serial")
Previous Message Alvaro Herrera 2003-05-27 20:06:10 Re: [Pgsql-ayuda] [Pgsql-ayuda] Número máximo de registros en una tabla