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"';
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
.)