I need a SQL query to check table name in which case.(upper/lower) For example I have table name 'USER' so that query should return UPPERCASE or in the case of table name 'user' it should return lower case.
Asked
Active
Viewed 391 times
1
-
Maybe this helps https://stackoverflow.com/q/6134006/3008984 – common sense Dec 19 '19 at 06:59
-
Does this answer your question? [Are table names in MySQL case sensitive?](https://stackoverflow.com/questions/6134006/are-table-names-in-mysql-case-sensitive) – Yasin Patel Dec 19 '19 at 07:15
1 Answers
1
You can use the below query to get whether the tables were created as upper/lower case.
SELECT
TABLE_NAME,
CASE TABLE_NAME REGEXP BINARY '[a-z]'
WHEN 1 THEN 'lower'
ELSE 'upper'
END AS case_status
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = 'table_name';

James
- 1,819
- 2
- 8
- 21