Skip to content

Instantly share code, notes, and snippets.

@maximal
Created July 5, 2022 08:35
Show Gist options
  • Save maximal/d713223dd716af0934ed6dd95076082d to your computer and use it in GitHub Desktop.
Save maximal/d713223dd716af0934ed6dd95076082d to your computer and use it in GitHub Desktop.
Структура таблиц MariaDB / MySQL
-- Структура таблиц MariaDB / MySQL
-- Порядок колонок не сохранён, таблицы и колонки отсортированы в алфавитном порядке
-- Удобно для сравнения структур нескольких баз, можно делать дифф
--
-- @since 2022-07-05
-- @author MaximAL
SELECT table_name, column_name, column_default, is_nullable, data_type,
character_maximum_length, character_octet_length, numeric_precision, numeric_scale,
datetime_precision, character_set_name, collation_name
FROM INFORMATION_SCHEMA.columns
WHERE table_schema = 'database_name'
ORDER BY table_name, column_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment