Skip to content

Instantly share code, notes, and snippets.

@maximal
Last active April 12, 2022 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximal/236e5806de3149a6a0adebdeba002935 to your computer and use it in GitHub Desktop.
Save maximal/236e5806de3149a6a0adebdeba002935 to your computer and use it in GitHub Desktop.
Структура таблиц PostgreSQL
-- Структура таблиц PostgreSQL
-- Порядок колонок не сохранён, таблицы и колонки отсортированы в алфавитном порядке
-- Удобно для сравнения структур нескольких баз, можно делать дифф
--
-- @since 2022-04-12
-- @author MaximAL
SELECT table_name, column_name, column_default, is_nullable, data_type,
character_maximum_length, character_octet_length, numeric_precision, numeric_precision_radix, numeric_scale,
datetime_precision, interval_type, interval_precision,
character_set_catalog, character_set_schema, character_set_name,
collation_catalog, collation_schema, collation_name
FROM INFORMATION_SCHEMA.columns
WHERE table_schema = 'public'
ORDER BY table_name, column_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment