Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IuryAnadao/60a1a9c147219b7adc62e1aeca079565 to your computer and use it in GitHub Desktop.
Save IuryAnadao/60a1a9c147219b7adc62e1aeca079565 to your computer and use it in GitHub Desktop.
Soluçoes de SQL's Postgresql
psql -h localhost -U gestor02aws -d kikker_production -c "SELECT pg_terminate_backend(pid), pid, application_name, state, (NOW() - backend_start) as atual, REGEXP_REPLACE(REPLACE(query, E'\n', ' '), ' ', '', 'g') as query FROM pg_stat_activity WHERE state = 'active' AND application_name LIKE 'Passenger%' and (query like '%stock_ruptures%' or query like '%ruptures_alert%') ORDER BY backend_start DESC;"
select
*
from jsonb_populate_recordset(null::record, $json) as (column type, column type)
SELECT
t.id,
inf.NOME_CHAVE_1,
inf.NOME_CHAVE_2,
inf.NOME_CHAVE_3
FROM table t
LEFT JOIN JSONB_TO_RECORD(t.informations) AS inf(NOME_CHAVE_1 char, NOME_CHAVE_2 numeric, NOME_CHAVE_3 char) ON TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment