Skip to content

Instantly share code, notes, and snippets.

@rdeavila
Last active June 13, 2024 01:35
Show Gist options
  • Save rdeavila/9214654 to your computer and use it in GitHub Desktop.
Save rdeavila/9214654 to your computer and use it in GitHub Desktop.
PostgreSQL: Lista todas as tabelas que tem um determinado campo.
SELECT
TABLE_NAME AS TABELA,
COLUMN_NAME AS CAMPO
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
COLUMN_NAME LIKE 'nome_campo%' -- Exemplo: 'id_empresa%'
AND COLUMN_NAME <> 'nome_campo_exclusao' -- Exemplo: 'id_empresaerp'
ORDER BY
TABELA ASC
@leydson-vieira
Copy link

Muito útil. Obrigado!

@maellson
Copy link

maellson commented Feb 7, 2019

ohhhh!! this save me! thanks!

@clestonv
Copy link

thanks!!

@RenanSS1
Copy link

Amigo obrigado pela ajuda, salvou minhas buscas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment