On 2012-01-23, panam wrote:
> Hi,
>
> If I'd like to have primary keys generated ("numeric" style, no UUIDs) that
> are unique across schemas is the best option to allocate a fixed sequence
> range (min,max) to the sequences of all schemas?
given that challenge the easiest solution is to just cre
On Fri, Jan 27, 2012 at 4:56 AM, panam wrote:
> Thanks, yeah, but the dummy tables are needed anyway in my case for those
> entities that are shared among the tenants :)
Ah! Then that's easy :)
ChrisA
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your
Thanks, yeah, but the dummy tables are needed anyway in my case for those
entities that are shared among the tenants :)
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Best-way-to-create-unique-primary-keys-across-schemas-tp5165043p5433562.html
Sent from the PostgreSQL -
On Thu, Jan 26, 2012 at 2:12 AM, panam wrote:
> CREATE TABLE tbl (ID bigint default nextval('global_seq') primary key,foo
> varchar,bar varchar); --in public schema
> CREATE TABLE schema1.tbl (LIKE public.tbl INCLUDING ALL); --draws ids from
> sequence in public schema
> CREATE TABLE schema2.tbl
OK, thanks for replys. To sum up, this is what I now consider best practice:
CREATE schema schema1;
CREATE schema schema2;
CREATE SEQUENCE global_seq; --in public schema
CREATE TABLE tbl (ID bigint default nextval('global_seq') primary key,foo
varchar,bar varchar); --in public schema
CREATE TA
On Wed, Jan 25, 2012 at 9:54 AM, panam wrote:
> What do you mean with "explicit sequence object"? An own sequence for each
> table per schema?
This:
On Wed, Jan 25, 2012 at 10:23 AM, Merlin Moncure wrote:
> Barring domains, you can just manually apply the default instead of
> using a serial typ
On 01/24/2012 04:23 PM, Merlin Moncure wrote:
> On Tue, Jan 24, 2012 at 5:23 AM, panam wrote:
>> Wow, this is pretty useful. Just to fit it more to my original use case, I
>> used this:
>>
>> CREATE schema schema1;
>> CREATE schema schema2;
>> CREATE TABLE tbl (ID serial primary key,foo varchar,
On Tue, Jan 24, 2012 at 5:23 AM, panam wrote:
> Wow, this is pretty useful. Just to fit it more to my original use case, I
> used this:
>
> CREATE schema schema1;
> CREATE schema schema2;
> CREATE TABLE tbl (ID serial primary key,foo varchar,bar varchar); --in
> public schema
> CREATE TABLE schem
Chris Angelico wrote
>
> I would recommend using an explicit sequence object rather than
> relying on odd behavior like this; for instance, if you now drop
> public.tbl, the sequence will be dropped too. However, what you have
> there is going to be pretty close to the same result anyway.
>
Oops
On Tue, Jan 24, 2012 at 10:23 PM, panam wrote:
> Wow, this is pretty useful. Just to fit it more to my original use case, I
> used this:
>
> CREATE TABLE tbl (ID serial primary key,foo varchar,bar varchar); --in
> public schema
> CREATE TABLE schema1.tbl (LIKE public.tbl INCLUDING ALL); --draws
Chris Angelico wrote
>
>
> You can "share" a sequence object between several tables. This can
> happen somewhat unexpectedly, as I found out to my surprise a while
> ago:
>
> CREATE TABLE tbl1 (ID serial primary key,foo varchar,bar varchar);
> INSERT INTO tbl1 (foo,bar) VALUES ('asdf','qwer');
On Mon, Jan 23, 2012 at 11:19 AM, panam wrote:
> Hi,
>
> If I'd like to have primary keys generated ("numeric" style, no UUIDs) that
> are unique across schemas is the best option to allocate a fixed sequence
> range (min,max) to the sequences of all schemas?
You can "share" a sequence object bet
On Sun, Jan 22, 2012 at 5:19 PM, panam wrote:
> Hi,
>
> If I'd like to have primary keys generated ("numeric" style, no UUIDs) that
> are unique across schemas is the best option to allocate a fixed sequence
> range (min,max) to the sequences of all schemas?
That's how I do it. If you use a bigs
Hi,
If I'd like to have primary keys generated ("numeric" style, no UUIDs) that
are unique across schemas is the best option to allocate a fixed sequence
range (min,max) to the sequences of all schemas?
Thanks
panam
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Best-w
14 matches
Mail list logo