Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChillarAnand/9d350132e82f9d675c4344127072f6bc to your computer and use it in GitHub Desktop.
Save ChillarAnand/9d350132e82f9d675c4344127072f6bc to your computer and use it in GitHub Desktop.
partman-delete
drop database sandbox;
create database sandbox;
\c sandbox;
create table author (
id serial primary key not null,
created_at timestamp with time zone not null,
updated_at timestamp with time zone not null,
name varchar(32)
)
;
CREATE SCHEMA partman;
CREATE EXTENSION pg_partman SCHEMA partman;
-- SELECT partman.create_parent('public.author', 'id', 'partman', '10');
insert into author values (
10,
'2010-01-01 21:49:22.742914+05:30',
'2010-01-01 21:49:22.742914+05:30',
'author1'
);
insert into author values (20,
'2020-01-01 21:49:22.742914+05:30',
'2020-01-01 21:49:22.742914+05:30',
'author2');
insert into author values (202002,
'2020-02-01 21:49:22.742914+05:30',
'2020-02-01 21:49:22.742914+05:30',
'author3');
insert into author values (
202004,
'2020-04-18 21:49:22.742914+05:30',
'2020-04-18 21:49:22.742914+05:30',
'author4'
);
insert into author (created_at, updated_at, name) values (now(), now(), 'author4');
insert into author (id, created_at, updated_at, name) values (141220, now(), now(), 'author4');
SELECT partman.create_parent('public.author', 'created_at', 'partman', 'daily');
select * from author order by created_at desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment