Re: Table Partitioning: Sequence jump issue 10 in 10 with serialdatatype - Mailing list pgsql-general

From DrakoRod
Subject Re: Table Partitioning: Sequence jump issue 10 in 10 with serialdatatype
Date
Msg-id 1518572939820-0.post@n3.nabble.com
Whole thread Raw
In response to Re: Table Partitioning: Sequence jump issue 10 in 10 with serial datatype  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Table Partitioning: Sequence jump issue 10 in 10 with serialdatatype  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general
Sorry, your right! The example is:

CREATE TABLE customers (
    id serial PRIMARY KEY,
    name TEXT,
    other_data TEXT
);

CREATE TABLE customers_part1(
 CHECK (id<10000)
)INHERITS (customers);

CREATE TABLE customers_part2(
 CHECK (id>=10000 AND id<20000)
)INHERITS (customers);

CREATE OR REPLACE RULE inserts_customer_part1
AS ON INSERT TO customers
WHERE new.id < 10000
DO INSTEAD  INSERT INTO customers_part1 SELECT NEW.*;

CREATE OR REPLACE RULE inserts_customer_part2
AS ON INSERT TO customers
WHERE new.id >= 10000 AND new.id < 20000
DO INSTEAD  INSERT INTO customers_part2 SELECT NEW.*;

INSERT INTO customers (name, other_data) VALUES ('XXXXXXx','YYYYYYYYYY');
INSERT INTO customers (name, other_data) VALUES ('XXXXXXx','YYYYYYYYYY');
INSERT INTO customers (name, other_data) VALUES ('XXXXXXx','YYYYYYYYYY');
INSERT INTO customers (name, other_data) VALUES ('XXXXXXx','YYYYYYYYYY');
INSERT INTO customers (name, other_data) VALUES ('XXXXXXx','YYYYYYYYYY');
INSERT INTO customers (name, other_data) VALUES ('XXXXXXx','YYYYYYYYYY');


dd=# SELECT * FROM customers;
 id |  name   | other_data
----+---------+------------
  3 | XXXXXXx | YYYYYYYYYY
  7 | XXXXXXx | YYYYYYYYYY
 11 | XXXXXXx | YYYYYYYYYY
 15 | XXXXXXx | YYYYYYYYYY
 19 | XXXXXXx | YYYYYYYYYY
 23 | XXXXXXx | YYYYYYYYYY
(6 rows)




-----
Dame un poco de fe, eso me bastará.
Rozvo Ware Solutions
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Table Partitioning: Sequence jump issue 10 in 10 with serial datatype
Next
From: Welkin
Date:
Subject: unsubsribe