What is the equivalent of 'go' in MySQL?

41,074

Solution 1

Semicolon at the end of the line.

INSERT INTO myTable (ID) values (5);

Solution 2

The semicolon is the default delimiter. You can however redefine it to whatever you want with the DELIMITER keyword. From the MySQL manual:

mysql> delimiter //

mysql> CREATE PROCEDURE simpleproc (OUT param1 INT)
    -> BEGIN
    ->   SELECT COUNT(*) INTO param1 FROM t;
    -> END;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;

mysql> CALL simpleproc(@a);
Query OK, 0 rows affected (0.00 sec)

This is not limited to stored procedure definitions of course.

Solution 3

I think the problem is that GO is a batch terminator, not a statement terminator. After explicitly setting transactions, I got this code to execute without telling me that the procedure already exists. Without the transaction statements, I do get an error that the procedure already exists.

start transaction; drop procedure if exists usp_test; commit; start transaction; CREATE PROCEDURE usp_test() SELECT * from books; commit; call usp_test();

Solution 4

Just a simple ;

so try

insert into myTable(ID) values (5);
select * from myTable;

Solution 5

Use a semicolon (;). It will separate your statements.

Share:
41,074
Ahmed Mozaly
Author by

Ahmed Mozaly

Updated on February 17, 2020

Comments

  • Ahmed Mozaly
    Ahmed Mozaly over 4 years

    In TSQL I can state:

    insert into myTable (ID) values (5)
    GO
    select * from myTable
    

    In MySQL I can't write the same query.

    What is the correct way to write this query in MySQL?