How to execute multiple SQL queries in MySQL Workbench?

I am using MySQL Workbench CE for Windows version 5.2.40.

I want to execute the following SQL queries together. However I can only execute the SQL queries by first executing the CREATE TABLE query, and then executing the INSERT INTO query and after that executing the SELECT query.

CREATE TABLE testTable(
    Name VARCHAR(20),
    Address VARCHAR(50),
    Gender VARCHAR(10)
)

INSERT INTO testTable
    VALUES
    ('Derp', 'ForeverAlone Street', 'Male'),
    ('Derpina', 'Whiterun Breezehome', 'Female')

Select * FROM testTable

So how do I execute the CREATE TABLE, INSERT INTO and the SELECT queries by one click?

Answers


Add a semicolon after each statement:

CREATE TABLE testTable(
    Name VARCHAR(20),
    Address VARCHAR(50),
    Gender VARCHAR(10)
);

INSERT INTO testTable
VALUES
('Derp', 'ForeverAlone Street', 'Male'),
('Derpina', 'Whiterun Breezehome', 'Female');

SELECT * FROM testTable;

You could use Ctrl+Shift+Enter to run everything with semicolon end.

For Mac ⌘+shift+return


Need Your Help

Select SQL Server database size

sql sql-server sql-server-2008 sql-server-2008-r2

how can i query my sql server to only get the size of database?

How can I avoid migration in RealmSwift

swift migration realm

I am just testing some configurations with Realm and therefore I have added and deleted variables and lists from my realm classes. Since I am just testing I do not want to go through the migration