mysql 检查表的排序规则
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3832056/
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
mysql check collation of a table
提问by Scott
How can I see what collation a table has? I.E. I want to see:
如何查看表的排序规则?IE 我想看:
+-----------------------------+
| table | collation |
|-----------------------------|
| t_name | latin_general_ci |
+-----------------------------+
回答by Lekensteyn
SHOW TABLE STATUS
shows information about a table, including the collation.
SHOW TABLE STATUS
显示有关表的信息,包括排序规则。
For example SHOW TABLE STATUS where name like 'TABLE_NAME'
例如 SHOW TABLE STATUS where name like 'TABLE_NAME'
回答by Moustafa Elqabbany
The above answer is great, but it doesn't actually provide an example that saves the user from having to look up the syntax:
上面的答案很好,但它实际上并没有提供一个示例,使用户不必查找语法:
show table status like 'test';
show table status like 'test';
Where test
is the table name.
test
表名在哪里。
(Corrected as per comments below.)
(根据下面的评论更正。)
回答by Giorgos Myrianthous
You can also query INFORMATION_SCHEMA.TABLES
and get the collation for a specific table:
您还可以查询INFORMATION_SCHEMA.TABLES
并获取特定表的排序规则:
SELECT TABLE_SCHEMA
, TABLE_NAME
, TABLE_COLLATION
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 't_name';
that gives a much more readable output in contrast to SHOW TABLE STATUS
that contains a lot of irrelevant information.
与SHOW TABLE STATUS
包含大量不相关信息的输出相比,这提供了更具可读性的输出。
Note that collation can also be applied to columns (which might have a different collation than the table itself). To fetch the columns' collation for a particular table, you can query INFORMATION_SCHEMA.COLUMNS
:
请注意,排序规则也可以应用于列(可能与表本身具有不同的排序规则)。要获取特定表的列排序规则,您可以查询INFORMATION_SCHEMA.COLUMNS
:
SELECT TABLE_SCHEMA
, TABLE_NAME
, COLUMN_NAME
, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 't_name';
回答by Rizwan Siddiquee
Use this query:
使用此查询:
SHOW CREATE TABLE tablename
You will get all information related to table.
您将获得与表相关的所有信息。
回答by jobin
This command describes
该命令描述
mysql> use <database name>
mysql> show table status like '<table name>';
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+---------------------+------------+--------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+---------------------+------------+--------------------+----------+----------------+---------+
| test | InnoDB | 11 | Dynamic | 52 | 315 | 16384 | 0 | 0 | 0 | 59 | NULL | 2020-04-16 23:00:00 | NULL | utf8mb4_unicode_ci | NULL | | |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+---------------------+------------+--------------------+----------+----------------+---------+
1 row in set (0.01 sec)