> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/system-tables/sys-schema/sys-schema-stored-functions/format_path.md).

# format\_path

{% hint style="info" %}
Sys Schema is available from MariaDB 10.6.
{% endhint %}

## Syntax

```
sys.format_path(path)
```

## Description

`format_path` is a [stored function](/docs/server/server-usage/stored-routines/stored-functions.md) available with the [Sys Schema](/docs/server/reference/system-tables/sys-schema.md) that, given a path, returns a modified path after replacing subpaths matching the values of various system variables with the variable name.

The system variables that are matched are, in order:

* [datadir](/docs/server/server-management/variables-and-modes/server-system-variables.md#datadir)
* [tmpdir](/docs/server/server-management/variables-and-modes/server-system-variables.md#tmpdir)
* [slave\_load\_tmpdir](/docs/server/ha-and-performance/standard-replication/replication-and-binary-log-system-variables.md#slave_load_tmpdir)
* [innodb\_data\_home\_dir](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_data_home_dir)
* [innodb\_log\_group\_home\_dir](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_log_group_home_dir)
* [innodb\_undo\_directory](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_undo_directory)
* [basedir](/docs/server/server-management/variables-and-modes/server-system-variables.md#basedir)

## Examples

```sql
SELECT @@tmpdir;
+------------------------------------+
| @@tmpdir                           |
+------------------------------------+
| /home/ian/sandboxes/msb_10_8_2/tmp |
+------------------------------------+

SELECT sys.format_path('/home/ian/sandboxes/msb_10_8_2/tmp/testdb.ibd');
+------------------------------------------------------------------+
| sys.format_path('/home/ian/sandboxes/msb_10_8_2/tmp/testdb.ibd') |
+------------------------------------------------------------------+
| @@tmpdir/testdb.ibd                                              |
+------------------------------------------------------------------+
```

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
