Skip to content

Instantly share code, notes, and snippets.

@sahapasci
sahapasci / create-partitioned-table.sql
Created May 20, 2020 15:20 — forked from edib/create-partitioned-table.sql
Migrate non-partioned table to a partitioned table.
-- base table
-- drop table users cascade;
CREATE TABLE users (
id serial PRIMARY KEY,
username text NOT NULL UNIQUE,
password text,
created_on timestamptz NOT NULL,
last_logged_on timestamptz NOT NULL
@sahapasci
sahapasci / gist:e766d2c2a0c2521ebb73e89ede971e84
Created April 18, 2019 14:50
postgresql 9.6 alter column type which used in function
create table my_table (id integer primary key, data text);
create function my_func(id integer, data text)
returns void
language plpgsql
as
$$
begin
insert into my_table values (id, data);
end;
$$;
@sahapasci
sahapasci / create_dms_selection_rules.sql
Created November 13, 2018 14:49
AWS DMS Selection Rules JSON
/*
* This query creates JSON input for AWS DMS (Data Migration Service) selection rules.
* It incluedes all schemas.
*/
WITH rules AS (
SELECT
format('{
"rule-type": "selection",
"rule-id": "%s",