This file contains hidden or 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 pg_size_pretty(pg_database_size('previsao')); |
This file contains hidden or 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 u.usename AS "User name", | |
| u.usesysid AS "User ID", | |
| CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('superuser, create | |
| database' AS pg_catalog.text) | |
| WHEN u.usesuper THEN CAST('superuser' AS pg_catalog.text) | |
| WHEN u.usecreatedb THEN CAST('create database' AS | |
| pg_catalog.text) | |
| ELSE CAST('' AS pg_catalog.text) | |
| END AS "Attributes" | |
| FROM pg_catalog.pg_user u |
This file contains hidden or 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 DISTINCT 'DROP TRIGGER ' || trigger_name ||' ON ' || event_object_schema || '.' || event_object_table || ';' FROM information_schema.triggers where trigger_name ilike '%bucardo%' and trigger_schema not ilike '%bucardo%' order by 1 |
This file contains hidden or 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 | |
| column_name, | |
| data_type, | |
| character_maximum_length | |
| from INFORMATION_SCHEMA.COLUMNS | |
| where table_name = 'condicoes_tempo_metar_ldm' | |
| AND table_schema = 'dados_ocorridos'; |
This file contains hidden or 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 crosstab | |
| ('SELECT gid, inicio_alerta, fim_alerta | |
| from monitoramento.alerta_gis_audit where gid=80287 and (operacao = ''I''or operacao = ''D'')') | |
| AS ct (gid int, inicio timestamp, fim timestamp); |
This file contains hidden or 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
| pg_dumpall -g > roles.sql |
This file contains hidden or 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
| #!/bin/sh | |
| # This script verifies that the postgresql data directory has been correctly | |
| # initialized. We do not want to automatically initdb it, because that has | |
| # a risk of catastrophic failure (ie, overwriting a valuable database) in | |
| # corner cases, such as a remotely mounted database on a volume that's a | |
| # bit slow to mount. But we can at least emit a message advising newbies | |
| # what to do. | |
| # | |
| # It's used directly from the systemd service file as a prelaunch check. |
This file contains hidden or 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
| with | |
| all_tables as | |
| ( | |
| SELECT * | |
| FROM ( | |
| SELECT 'all'::text as table_name, | |
| sum( (coalesce(heap_blks_read,0) + coalesce(idx_blks_read,0) + coalesce(toast_blks_read,0) + coalesce(tidx_blks_read,0)) ) as from_disk, | |
| sum( (coalesce(heap_blks_hit,0) + coalesce(idx_blks_hit,0) + coalesce(toast_blks_hit,0) + coalesce(tidx_blks_hit,0)) ) as from_cache | |
| FROM pg_statio_all_tables --> change to pg_statio_USER_tables if you want to check only user tables (excluding postgres's own tables) | |
| ) a |
This file contains hidden or 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 'drop table \"' || tablename || '\" cascade;' from pg_tables where schemaname='public' |
This file contains hidden or 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 'DROP FUNCTION ' || ns.nspname || '.' || proname | |
| || '(' || oidvectortypes(proargtypes) || ');' | |
| FROM pg_proc INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid) | |
| WHERE ns.nspname = 'bucardo' order by proname; |