MariaDB 10でデータベースの情報をクエリで取得する
環境
Windows10 home 64bit
MariaDB 10.6.4
書式
select * from information_schema.schemata
where
schema_name='データベース名'
select * from information_schema.schemata
where
schema_name='データベース名'
select * from information_schema.schemata where schema_name='データベース名'
schema_nameを利用して、データベースの情報をクエリで取得します。
操作
SQL構文
select * from information_schema.schemata
where
schema_name='testdb'
select * from information_schema.schemata
where
schema_name='testdb'
select * from information_schema.schemata where schema_name='testdb'
実行結果
MariaDB [(none)]> select * from information_schema.schemata
-> where
-> schema_name='testdb';
+--------------+-------------+----------------------------+------------------------+----------+----------------+
| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH | SCHEMA_COMMENT |
+--------------+-------------+----------------------------+------------------------+----------+----------------+
| def | testdb | utf8mb3 | utf8mb3_general_ci | NULL | |
+--------------+-------------+----------------------------+------------------------+----------+----------------+
1 row in set (0.001 sec)
MariaDB [(none)]> select * from information_schema.schemata
-> where
-> schema_name='testdb';
+--------------+-------------+----------------------------+------------------------+----------+----------------+
| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH | SCHEMA_COMMENT |
+--------------+-------------+----------------------------+------------------------+----------+----------------+
| def | testdb | utf8mb3 | utf8mb3_general_ci | NULL | |
+--------------+-------------+----------------------------+------------------------+----------+----------------+
1 row in set (0.001 sec)
MariaDB [(none)]> select * from information_schema.schemata -> where -> schema_name='testdb'; +--------------+-------------+----------------------------+------------------------+----------+----------------+ | CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH | SCHEMA_COMMENT | +--------------+-------------+----------------------------+------------------------+----------+----------------+ | def | testdb | utf8mb3 | utf8mb3_general_ci | NULL | | +--------------+-------------+----------------------------+------------------------+----------+----------------+ 1 row in set (0.001 sec)