Skip to content

Instantly share code, notes, and snippets.

View sebastianwebber's full-sized avatar
🏠
Working from home

Sebastian Webber sebastianwebber

🏠
Working from home
View GitHub Profile
@sebastianwebber
sebastianwebber / executa_vfull.sh
Created November 30, 2015 19:52
Executar Vacuum FULL e Reindex no sistema AvaCorp
#!/bin/bash
PG_HOME="/usr/pgsql-9.3"
${PG_HOME}/vacuumdb -U postgres -d jetclass
${PG_HOME}/reindexdb -U postgres jetclass
@sebastianwebber
sebastianwebber / README.md
Last active December 2, 2015 12:28
Laborário PostgreSQL Administração - Módulo 5: Backup

Instruções

Faça o download o script no diretório /root/lab (crie-o se necessário):

wget https://gist.githubusercontent.com/sebastianwebber/680bfddd6cb5c84ba809/raw/a9b00d047f751145c69abf523dba7a3bf880f9ea/lab5-1.sh -O ~/lab/lab5-1.sh

Ajuste as permissões necessárias:

chmod +x ~/lab/lab5-1.sh

PoWA on FreeBSD

Installation

OS Dependencies

Install pgxnclient and py-pip packages.

PostgreSQL Modules

pgxnclient install powa
@sebastianwebber
sebastianwebber / create_imdb.sh
Created January 13, 2016 01:30
Converts IMDB into PostgreSQL database
#!/bin/bash
## This script download the data and clone imdb-to-sql repo on github
## Requirements:
### - Python 2.6+
### - psycopg2 python lib
### - git client
### - wget
@sebastianwebber
sebastianwebber / Vagrantfile.rb
Last active March 11, 2017 22:57
Desafio Replicação PostgreSQL
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
@sebastianwebber
sebastianwebber / new-owner.sql
Created February 1, 2016 18:24
SELECT to generate new table owner in PostgreSQL
SELECT
'ALTER TABLE ' ||
schemaname || '.' || relname ||
' OWNER TO novo_user;'
FROM pg_stat_user_tables;
@sebastianwebber
sebastianwebber / oracle-trace-helper.sql
Created March 1, 2016 17:44
SELECT to generate SQL statement to exec trace command
SELECT
'exec SYS.DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION (' || p.pid || ', ' || p.serial# || ', true); ' AS start_trace_cmd,
p.tracefile
FROM v$process p, v$session s
WHERE p.addr = s.paddr
AND LOWER(s.username) LIKE LOWER('%user_name%');
@sebastianwebber
sebastianwebber / README.md
Last active March 10, 2016 18:19
ModCluster 1.3.1 WITH TCP on CEntOS 7x

Download httpd with mod_cluster

You can download the mod_cluster binaries on the mod_cluster website:

Install httpd packages

yum install httpd mod_ssl
@sebastianwebber
sebastianwebber / bdr-freebsd.md
Last active September 24, 2017 06:35
Install BDR on FreeBSD

BDR Core (currently a fork from postgres project)

Before start, run:

mkdir -p /opt/resources
cd /opt/resources

Clone the BDR source, using the latest branch:

@sebastianwebber
sebastianwebber / exemplo.sql
Created April 23, 2016 19:06
exemplo de trabalhar com dias da semana
sebastian=# CREATE TABLE notas (id serial primary key, ano smallint, semana smallint, nota numeric(5,2));
CREATE TABLE
sebastian=# INSERT into notas (ano, semana, nota) VALUES(2016, 2, 83.7);
INSERT 0 1
sebastian=# SELECT
sebastian-# (ano || '-01-01')::DATE + (semana ||' weeks')::INTERVAL AS data_inicial,
sebastian-# nota
sebastian-# FROM notas;
data_inicial | nota
---------------------+-------