Last active
August 23, 2021 13:28
-
-
Save IuryAnadao/60a1a9c147219b7adc62e1aeca079565 to your computer and use it in GitHub Desktop.
Soluçoes de SQL's Postgresql
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
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;" |
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 jsonb_populate_recordset(null::record, $json) as (column type, column type) |
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 | |
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