1. Home
  2. Docs
  3. Query Builder
  4. Writing queries

Writing queries

You must be an admin user to use the Query Builder

Write and execute SQL queries

The Query Builder starts with an empty tab. SQL commands are written in the editor below the tab. Select a database, enter a query in the editor and press the Execute button.

Multiple SQL commands

The Query Builder does not only support queries. It basically supports any SQL command (DCL, DDL and DML) as long as you have the necessary privileges. If you are ISP hosted, your privileges will be limited.

Write / on an empty line to separate SQL commands. Example:

drop table if exists x

create table x
(x int)

insert into x values(1)

insert into x values(2)

update x
set x = x + 100

select *
from x

Will result in 6 tabs. Each tab is related to a query/command and shows the query results for that specific SQL statement.

User defined variables and dynamic queries

The Query Builder supports used defined variables and dynamic queries. Here is an example:

SET @column = "columnname"

SET @table = "tablename"

SET @select = CONCAT("SELECT ", @column, " FROM ", @table)

PREPARE stmt FROM @select


> Read more about user defined variables…

Protect WordPress tables

WordPress tables are protected by default. It is possible to disable this protection with restrictions. For obvious reasons it is not possible to DROP, ALTER or TRUNCATE WordPress tables in general. With WordPress table protection disabled, the plugin allows users to perform INSERT, UPDATE and DELETE operations on WordPress tables. Making changes to WordPress tables is not recommended!

Database response

The database response is shown in a scrollable table below the editor. The table data can be exported to CSV, JSON and XML.

View raw output

Use the icon below the scrollable table to view the raw database output. The output is shown in JSON format and is read-only.

Save query

Double click on the tab to give the query a name. Click Save to save the query.

Open query

Click the arraw down icon in the page title, select the query from the list and click Open selected. The listbox contains only query that are currently not edited.

Open all queries

Click the arraw down icon in the page title and click Open all. The listbox contains only query that are currently not edited.

Execution time

Add the following lines to your wp-config.php to show the execution time between round brackets (see screenshot above – click to enlarge):

define( 'WP_DEBUG_LOG', true );
define( 'SAVEQUERIES', true );
Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published.