Working with saved queries
You can save any query to use it later and create a template out of it. The
- Save a query as a template.
- Use a saved query.
- Edit a saved query.
- Publish a saved query.
- Configure access permissions for a published query.
- Delete a saved query.
Saving a query as a template
To save a query:
- In the
Connections section, connect to the database and go to the query editor. - In the data panel, click
next to the Execute button. - In the Save query window:
-
Select the database to query. By default, the current database is specified in this field.
-
Specify a Name, i.e., any name under which the query will be displayed in the list of saved queries.
-
For your saved query to be used as a template in the suggestions list, select Add tip and type the Tip text including
userTemplate_
.Tip
If you add a suggestion and specify a template name, you can include in the query the arguments to be highlighted when this template is selected, such as
SELECT $1 FROM employees LIMIT $2
. -
Review or edit the query.
-
Click Save.
-
-
Open Yandex WebSQL
. -
Go to the
Saved queries section. -
In the top-right corner, click
. -
In the window that opens:
-
Select a connection to the queried database.
-
Specify a Name, i.e., any name under which the query will be displayed in the list of saved queries.
-
For your saved query to be used as a template in the suggestions list, select Add tip and type the Tip text including
userTemplate_
.Tip
If you add a suggestion and specify a template name, you can include in the query the arguments to be highlighted when this template is selected, such as
SELECT $1 FROM employees LIMIT $2
. -
Enter the query text.
-
Click Save.
-
After you save the query, it will appear in the
Using a saved query
-
Begin typing
template
in the query field.
The suggestions list will show the saveduserTemplate_*
templates and ready-made templates:template_CREATE
template_DELETE
template_DROP_TABLE
template_INSERT
template_SELECT
template_UPDATE
-
Select the template you need from the suggestions list.
-
Add relevant parameters to the template. Use the
TAB
key to switch between the parts of the template you are adding parameters to. -
Click Run.
- Go to the
Saved queries section. - Click
to the right of the query you need and select Use query: it will show up in the data panel. - Click Open in editor.
- (Optional) Update query parameters.
- Click Execute.
Editing a saved query
To edit a saved query:
-
Go to the
Saved queries section. -
Click
to the right of the query you need and select Edit query. -
In the window that opens:
-
Select the database to query.
-
Specify a Name, i.e., any name under which the query will be displayed in the list of saved queries.
-
Add, edit, or delete a suggestion.
Tip
If you add a suggestion and specify a template name, you can include in the query the arguments to be highlighted when this template is selected, such as
SELECT $1 FROM employees LIMIT $2
. -
Review or edit the query.
-
-
Click Save.
Publishing a query
You can publish your query. Once published, the query will be available to all folder users. You cannot unpublish a query.
To publish a query:
-
Go to the
Saved queries section. -
Click
to the right of the query you need and select Publish query. -
In the window that opens, click Publish.
You will see
Configuring access permissions for a published query
To configure access permissions:
-
Go to the
Saved queries section. -
Click
to the right of the query you need and select Access permissions. -
In the window that opens, click Assign roles.
-
Assign the required roles and click Save.
Deleting a saved query
To delete a saved query:
-
Go to the
Saved queries section. -
Click
to the right of the query you need and select Delete. -
In the window that opens, click Apply.