Last active
March 6, 2017 21:11
-
-
Save saicitus/cc173b96db312fcd25bf807dd49cd9e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE example_serial(id serial, name text, created_at timestamp); | |
SELECT create_distributed_table('example_serial', 'id'); | |
INSERT INTO example_serial (name, created_at) VALUES ('My test', now()); | |
-- ERROR: values given for the partition column must be constants or constant expressions | |
-- Work around: | |
-- 1) Create a sequence 'seq' on the coordinator node: | |
CREATE SEQUENCE seq; | |
-- 2) Calucate the nextval of the sequence in the app layer using the following SQL. | |
select nextval('seq'); | |
-- 3) Place the above value in 'id_val' variable in your application and then do the insert | |
INSERT INTO example_serial (id, name, created_at) VALUES (id_val, 'My test', now()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment