Amit Joshi
Amit Joshi

Reputation: 35

How to get table name in which case

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.

Upvotes: 1

Views: 564

Answers (1)

James
James

Reputation: 1829

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';

Upvotes: 1

Related Questions