Ciao ,
quando un campo è progressivo, come lo creo in postgres?
ed un campo cosice univoco?
grazie
Ciao ,
quando un campo è progressivo, come lo creo in postgres?
ed un campo cosice univoco?
grazie
Se dichiari il campo come "serial" il postgres automaticamente crea una sequenza.
Il comportamento è identico a quello dei campi autoincrementanti del mysql
esempio:
mioid serial primary key
Ciao
In a world without walls and fences - who needs windows and gates ?
in quell' esempio ho un campo autoincrementato solo?
e per un campo univoco?
ciao grazie
Se è impostato come chiave primaria è sicuramente univoco.
In realtà il tipo serial viene implementato con una sequenza cioè una specie di contatore incrementante a parte.
create table test (myid serial);
è come scrivere
-- crea la sequenza
create sequence test_myid_seq;
-- crea la tabella impostando la sequenza come chiave
-- che viene incrementata dalla funzione postgres nextval
create table test (myid integer unique not null
default nextval('test_myid_seq'));
In a world without walls and fences - who needs windows and gates ?
ok grazie e un float?..