![]() ![]() Same steps you can follow with other table and use the common sequence with them. Now, attach the function with table: Create table mytab( ![]() Now, you can create a function like below to access the sequence for each insert: CREATE OR REPLACE FUNCTION public.func() ![]() ‘.XX’, port ‘5432’, dbname ‘mydatabase’) ĬREATE USER MAPPING FOR PUBLIC SERVER global_seq OPTIONS (user ‘User’ ,ĬREATE FOREIGN TABLE seqtable (a bigint) SERVER global_seq OPTIONS ( Now, We will be using a foreign data wrapper to access the sequence: CREATE EXTENSION postgres_fdw ĬREATE SERVER global_seq FOREIGN DATA WRAPPER postgres_fdw OPTIONS(host Like below: create sequence seq Ĭreate a view on this sequence: CREATE VIEW seq_view AS SELECT nextval(‘seq’) as a You can create a sequence and make it global.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |