In order to pass a stored procedure to the server as a whole, we declare a new delimiter that won't allow MySQL to interpret statements one at a time. So, our procedure would look something like:
delimiter $$
create procedure some_procedure()
begin
insert into table1 select * from table2;
select * from table1;
end $$
delimiter ;
Notice that there are actually two "things" grouping our code base. They are BEGIN-END keywords and $$ delimeter. My question is why we need them both and isn't it redundant?
If someone plans on answering that we must specify BEGIN-END because of the stored procedure's syntax, they would be wrong as it is not mandatory if it contains a single query:
create procedure another_procedure()
select * from table2;
Can someone tell me what am I missing here?