Write and execute SQL queries #
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 #
SET @column = "columnname"
/
SET @table = "tablename"
/
SET @select = CONCAT("SELECT ", @column, " FROM ", @table)
/
PREPARE stmt FROM @select
/
EXECUTE stmt
/
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 );