From: barbara cioppa <barbara_cioppa@yahoo.com>
To: pgsql-it-generale@postgresql.org <pgsql-it-generale@postgresql.org>
Subject: problema con autoincremento nextval
Date: Fri, 13 Jan 2012 03:25:54 -0800 (PST)
Message-ID: <1326453954.52470.YahooMailNeo@web45110.mail.sp1.yahoo.com> (raw)
Salve a tutti,
spero di essere nella mailing list giusta.
Ho bisogno di creare una colonna autoincrementale, la classica ID.
Ho creato una sequenza numID e il codice sql generato dal mio PGAdmin III ver 1.12.3, è il seguente:
CREATE SEQUENCE "Pratiche"."numID"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE "Pratiche"."numID" OWNER TO postgres;
GRANT ALL ON TABLE "Pratiche"."numID" TO postgres;
GRANT ALL ON TABLE "Pratiche"."numID" TO public;
COMMENT ON SEQUENCE "Pratiche"."numID" IS 'uso per creare id autoincrementali';
a questo punto da una delle tabelle che necessitano di un campo autoincrementale, scrivo nel campo dell'interfaccia "valore predefinito" dell'attributo ID della tab. pratica nextval('numID'), così diventa
ID integer not null default nextval('numID')
ma quando premo ok mi appare un popup "si è verificato un errore, error relation numid does not exist".
Dove sbaglio?
Inoltre se due tabelle, supponiamo A e B necessitano di un campo autoincrementale come faccio ad usare la stessa sequenza? Se con A sono arrivata al num. 10 su B se chiamo nextval, ottengo 11 oppure memorizza il valore che dovrebbe chiamare B senza tener conto di A.
Esempio su A nextval (SEQx) -->1
A nextval (SEQx) --->2
A nextval (SEQx) --->3
b nextval (SEQx) -->1 O 4?
GRAZIE MILLE A CHI MI RISPONDERA'.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-it-generale@postgresql.org
Cc: barbara_cioppa@yahoo.com
Subject: Re: problema con autoincremento nextval
In-Reply-To: <1326453954.52470.YahooMailNeo@web45110.mail.sp1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox