# 用户参数

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/idea/llms.txt).

> **TL;DR**
> 按 `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) 打开设置，然后转到  `工具 | 数据库 | 查询执行 | 用户参数` 。

有关使用用户参数的更多信息，请参考 [运行查询相关章节](run-a-query.html#user_parameters)主题。

|  条目  |  描述  |
| --- | --- |
|    在查询控制台和 SQL 文件中启用    |     将形参模式应用于 SQL 文件和 查询控制台s 中的 SQL。 可以在 [单个模式](#usage_scope)级别限制用法作用域。       如果清除此复选框，则无论为各个模式指定的用法作用域如何，都不会在 SQL 文件和 查询控制台s 中使用这些模式。     |
|    使用 SQL 注入在字符串字面量中启用    |     将参数模式应用于 [注入](using-language-injections.html) SQL 的字符串文字。 如有必要，可以在 [单个模式](#usage_scope)级别限制用法作用域。       如果清除此复选框，则无论为单个模式指定的用法作用域如何，都不会在字符串文字中使用这些模式。     |
|    在 SQL 字符串中替换    |     将参数模式应用于 SQL 代码中的字符串字面量。       例如，考虑以下代码。       ```SQL SELECT ${column_name} FROM actor WHERE actor_id='${actor_id}' ```      如果取消选中复选框，IntelliJ IDEA 只会在其中找到  `column_name`  参数。 该  `actor_id` 参数被视为字符串。       但是如果您选择了   在 SQL 字符串中替换  选项，  `actor_id`  参数将被视为用户参数。      已禁用:    ![SQL 字符串内部替换设置已禁用](https://resources.jetbrains.com/help/img/idea/2026.3/db_settings_substitute_inside_sql_strings_off.png)   已启用:    ![已启用“替换 SQL 字符串内的内容”设置](https://resources.jetbrains.com/help/img/idea/2026.3/db_settings_substitute_inside_sql_strings_on.png)    |
|    形参模式    |     形参模式及其用法作用域的列表。       模式使用正则表达式指定。 位于圆括号  `()`  中的值将被视为参数名称。 最初提供的模式有以下含义：        * `\?(\d+)` — 一个问号后跟一个或多个数字，例如， `?69` ，在这种情况下， `69` 将是参数名称。    * `%\w+` - `%` 后跟一个或多个单词字符，例如 `%xyz` 。    * `\$\{([^$\{\}]*)\}` - `$` ，然后 `{` ，然后除 `$` 、 `{` 或 `}` 外的任意字符零次或多次，然后 `}` ，例如， `${}` 、 `${value}` 。    * `\$\(([^\)]+)\)` - `$` ，然后 `(` ，然后任意字符（除 `)` 外）一次或多次，然后 `)` ，例如，$(x)。    * `\$(\w+)\$` - `$` ，然后是一个或多个单词字符，然后再次是 `$` ，例如 `$x1$` 。    * `\#（\w+）\#` - `#` ，然后是一个或多个单词字符，然后再次是 `#` ，例如 `#field_3#` 。      有关参数命名行为的详细信息，请参阅 [命名行为](run-a-query.html#naming_behavior)。       使用 !["添加"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg) `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))、 !["移除"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg) `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))、 ![上一个出现按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.up.svg) `Alt+Up` (Windows), `⌃ ⇧ ↑` (macOS), `⌃ ↑` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ ↑` (macOS System Shortcuts), `Alt+Up` (XWin), `Alt+Up` (GNOME), `Alt+Up` (KDE), `Alt+Up` (Emacs), `Alt+Up` (Sublime Text), `Alt+Up` (Sublime Text (macOS)), `Alt+Up` (Visual Studio), `⌃ ⇧ ↑` (Visual Studio (macOS)), `Ctrl+Alt+Up` (NetBeans), `Ctrl+Shift+Up` (Eclipse), `⌃ ⌥ ↑` (Eclipse (macOS)) 和 ![下一个匹配项按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.down.svg) `Alt+Down` (Windows), `⌃ ⇧ ↓` (macOS), `⌃ ↓` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ ↓` (macOS System Shortcuts), `Alt+Down` (XWin), `Alt+Down` (GNOME), `Alt+Down` (KDE), `Alt+Down` (Emacs), `Alt+Down` (Sublime Text), `Alt+Down` (Sublime Text (macOS)), `Alt+Down` (Visual Studio), `⌃ ⇧ ↓` (Visual Studio (macOS)), `Ctrl+Alt+Down` (NetBeans), `Ctrl+Shift+Down` (Eclipse), `⌃ ⌥ ↓` (Eclipse (macOS)) 来添加、删除和重新排序模式。       要编辑模式或其适用范围，请点击该模式并使用以下控件：        * 在脚本中 ：如果不得在 SQL 文件和 查询控制台s 中使用该模式，请清除此复选框。    * 在字面量中 ：如果模式不应在注入 SQL 的字符串文字中使用，请取消选中此复选框。    * 所有语言 ：点击链接，并清除不想使用该模式的语言复选框。    |

