This function takes a file path and returns the schema name it belongs to, assuming the file is located within the schema's directory.
sys.extract_schema_from_file_name(path)extract_schema_from_file_name is a available with the .
Given a file path, it returns the schema (database) name. The file name is assumed to be within the schema directory, and therefore the function will not return the expected result with partitions, or when tables are defined using the DATA_DIRECTORY table option.
The function does not examine anything on disk. The return value, a VARCHAR(64), is determined solely from the provided path.
This page is licensed: CC BY-SA / Gnu FDL
SELECT sys.extract_schema_from_file_name('/usr/local/mysql/data/db/t1.ibd');
+----------------------------------------------------------------------+
| sys.extract_schema_from_file_name('/usr/local/mysql/data/db/t1.ibd') |
+----------------------------------------------------------------------+
| db |
+----------------------------------------------------------------------+