Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With mysql show tables; can I sort by table name while ignoring case?

Tags:

mysql

Is there a way to sort the list of tables returned by mysql's 'show tables' command?

mysql> show tables;

I'd like to sort alphabetically by the table name.

EDIT:

As pointed out by one of the answers, they are already in alphabetical order. However, A != a. Is there a way to ignore case in the sort?

like image 337
Matthew Avatar asked Jun 29 '11 23:06

Matthew


People also ask

Can I use order as table name in MySQL?

As you know, order is a keyword in MySQL, you cannot give table name order directly. You need to use backtick around the table name order. Backtick allow a user to consider the keyword as table or column name. Insert some records in the table using insert command.

Is SQL case-sensitive for table name?

Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup.

Are table and column names case-sensitive?

Table and column names are already case-insensitive, unless you are querying them as values within information_schema views.

Should you treat database table and column names as case-sensitive or case-insensitive?

Field (column) names are case-insensitive regardless.


1 Answers

Query information_schema and replace database_name with the name of the database you want to return the tables from

SELECT table_name, engine
FROM information_schema.tables    
WHERE table_type = 'BASE TABLE' AND table_schema='database_name'  
ORDER BY table_name ASC;
like image 115
Christopher Manning Avatar answered Nov 15 '22 17:11

Christopher Manning