简体   繁体   中英

Run a SQL Script without displaying result in result window

I have a DB initialization script, which does several hundred inserts to the DB... every time I release, I need to run this script and I always get a notification, that I have too many result windows for this script. This is how the script looks like:

My SQL script contains a mix of select and insert statements like this:

-- I don't want these select statements to produce any result in the result window
SELECT @var1 := col1 FROM table1 WHERE col1 = 'some value';
SELECT @var2 := col2 FROM table2 WHERE col2 = 'some other value';

INSERT INTO table3(col1) VALUES(@var1);
INSERT INTO table4(col1) VALUES(@var2);

Is there any SQL command that I could include on top of this long script, which tells MySQL Workbench (V 6.3) that I am not interested in seeing the result for this particular script?

The Output is located at the bottom of MySQL Workbench. Its select box includes the Action Output, History Output, and Text Output options.

The Action Output panel displays a summary of the communication between the active MySQL connection in MySQL Workbench and the MySQL server, and can refer to errors or general information.

The History Output panel provides a history of SQL operations carried out in MySQL Workbench for the active MySQL connection. The time and SQL code for each operation is recorded.

Switch from "Action Output" to "History Output"

https://dev.mysql.com/doc/workbench/en/wb-develop-sql-editor-history.html

Thanks to the comment by @MikeLischke, I used Do command to execute the select statements, without producing any result in the result window:

DO (SELECT @var1 := col1 FROM table1 WHERE col1 = 'some value');
DO (SELECT @var2 := col2 FROM table2 WHERE col2 = 'some other value');

INSERT INTO table3(col1) VALUES(@var1);
INSERT INTO table4(col1) VALUES(@var2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM