Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query to show all tables and their collation

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.

like image 860
Parris Varney Avatar asked Feb 09 '11 17:02

Parris Varney


People also ask

How can check all table collation in SQL Server?

To view the collation setting of a database In Object Explorer, connect to an instance of the Database Engine and on the toolbar, click New Query. In the query window, enter the following statement that uses the sys. databases system catalog view. SELECT name, collation_name FROM sys.

How do you find the table collation?

Finding collation of a column in a table. In SSMS, go to the table, then columns, and finally right-click the individual columns to view the “Properties”. If the column is of a character data type, you will see details of the collation.

How can I see all table collations in MySQL?

The quickest way to return the collation of a given table in MySQL is to run the following statement: SHOW TABLE STATUS LIKE '%Artists%'; Running this statement will return a whole bunch of columns that provide information about any matching table/s.


2 Answers

SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLLATION_NAME     FROM INFORMATION_SCHEMA.COLUMNS 
like image 91
Joe Stefanelli Avatar answered Sep 21 '22 16:09

Joe Stefanelli


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; 
like image 28
ThiagoPXP Avatar answered Sep 21 '22 16:09

ThiagoPXP