Created
April 21, 2020 05:25
-
-
Save ChillarAnand/9d350132e82f9d675c4344127072f6bc to your computer and use it in GitHub Desktop.
partman-delete
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
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