MySQL 查询以显示所有表及其排序规则

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4948356/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:41:47  来源:igfitidea点击:

Query to show all tables and their collation

mysqlschemacollation

提问by Parris Varney

Is there a query that can be run in mysql that shows all tables and their default collation? Even better if there was on that could show all collations on all columns of all tables.

是否有可以在 mysql 中运行的查询来显示所有表及其默认排序规则?如果可以显示所有表的所有列上的所有排序规则,那就更好了。

回答by Joe Stefanelli

SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLLATION_NAME
    FROM INFORMATION_SCHEMA.COLUMNS

回答by ThiagoPXP

Bear in mind that collation can be defined to tables and also to columns.

请记住,可以为表和列定义排序规则。

A column's collation might be different to its parent table. Here is a query to get the collation from tables (not columns)

列的排序规则可能与其父表不同。这是一个从表(不是列)中获取排序规则的查询

SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_COLLATION
FROM INFORMATION_SCHEMA.TABLES;

回答by Andrinux

Output information(status) about all tables in the database as "phpmyadmin":

将数据库中所有表的信息(状态)输出为“phpmyadmin”:

SHOW TABLE STATUS FROM your_db_name;