0

I am trying to select the default collation of a database server value using php code. So far I was able to accomplish it using the following select statement. But when the default collation value was changed by me the result of the query remained the same. However I want this to be able to select from both mySQL and MariaDB while having a robust method to do this thanks.

$sql = 'SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME ='.'"information_schema"';
Fenn-CS
  • 863
  • 1
  • 13
  • 30
  • 1
    Possible duplicate of [How do I see what character set a MySQL database / table / column is?](http://stackoverflow.com/questions/1049728/how-do-i-see-what-character-set-a-mysql-database-table-column-is) – gus27 Mar 11 '17 at 07:22

1 Answers1

0

The "default" CHARACTER SET for the database is just that, a "default". It is used only(?) when you do CREATE TABLE without specifying a CHARACTER SET on the create table.

So, don't bother with it. Instead, explicitly specify the charset on CREATE TABLE.

But, then, that is just a default for each char/text column.

(Ditto for COLLATION.)

Rick James
  • 135,179
  • 13
  • 127
  • 222