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
# Run on Master | |
# Replace slave-ip and master-ip with actual ip addresses of those machines | |
CREATE USER repl; | |
GRANT REPLICATION SLAVE ON *.* TO repl_user@'slave-ip' IDENTIFIED BY 'passwd'; | |
# Run on Slave | |
CHANGE MASTER TO MASTER_HOST = 'master-ip', MASTER_PORT = 3306, MASTER_USER = 'repl', MASTER_PASSWORD = 'passwd'; | |
START SLAVE; | |
# To check the Status of Replication |
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 type order_status as enum ( | |
'placed', | |
'accepted', | |
'cancelled_by_customer', | |
'cancelled_by_restaurant', | |
'delivered' | |
); | |
drop table if exists orders; | |
create table orders ( |
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
select name, | |
unnest(schedule), | |
unnest(pay_by_quarter) | |
from sal_emp; |
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 array_fn (test_array text[]); | |
insert into array_fn values ('{This,Is,What,Bothers,Me}'); | |
select test_array[3]::varchar from array_fn; |
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 sal_emp ( | |
name text, | |
pay_by_quarter integer[], | |
schedule text[][] | |
); | |
insert into sal_emp | |
values ('Bill', | |
'{10000, 10000, 10000, 10000}', | |
'{{"meeting", "lunch"}, {"training", "presentation"}}'); |
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
select edge_id, | |
(dp).path[1] As index, | |
ST_AsText((dp).geom) As wktnode | |
from (select 1 As edge_id, | |
ST_DumpPoints(ST_GeomFromText('LINESTRING(1 2, 3 4, 10 10)')) as dp | |
union all | |
select 2 As edge_id, | |
ST_DumpPoints(ST_GeomFromText('LINESTRING(3 5, 5 6, 9 10)')) as dp | |
) as foo; |
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 function if exists transformation_utils.remove_invalid_characters (p_string text); | |
create or replace function transformation_utils.remove_invalid_characters (p_string text) | |
returns text AS | |
$body$ | |
declare | |
c text; | |
begin | |
select replace(p_string,'�','') into c; | |
return c; | |
end; |
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
select * from json_to_record('{ | |
"id": "pay_29QQoUBi66xm2f", | |
"entity": "payment", | |
"amount": 5000, | |
"currency": "INR", | |
"status": "captured", | |
"order_id": null, | |
"invoice_id": null, | |
"international": false, | |
"method": "wallet", |
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
{ | |
"id": "pay_29QQoUBi66xm2f", | |
"entity": "payment", | |
"amount": 5000, | |
"currency": "INR", | |
"status": "captured", | |
"order_id": null, | |
"invoice_id": null, | |
"international": false, | |
"method": "wallet", |
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 function if exists transformation_utils.ts_to_isodate (p_timestamp timestamp); | |
create or replace function transformation_utils.ts_to_isodate (p_timestamp timestamp) | |
returns integer AS | |
$body$ | |
declare | |
d integer; | |
begin | |
select to_char(p_timestamp::timestamp, 'YYYYMMDD') into d; | |
return d; | |
end; |
NewerOlder