MariaDB 10でデータベースの情報をクエリで取得する

2022年4月3日

環境
Windows10 home 64bit
MariaDB 10.6.4

書式

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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'

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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)

 

MariaDB

Posted by arkgame