9

I can't execute MySQL statement when using delimiter (default ';'). I mean, when I run query like:

select * from mdw.dim_date dd limit 10;
select * from mdw.dim_order do limit 5;

I've got such error:

SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select * from mdw.dim_order do limit 5' at line 2

I don't want to execute this per Alt+X (I am using Dbeaver) as I want to put query into pentaho. I need to execute around 50 deletes, so I don't want to divide it on 50 SQL scripts.

I am using MySQL (version: 5.6.36-82.0).

3
  • Most database APIs only allow you to execute one query at a time.
    – Barmar
    Sep 11, 2020 at 16:01
  • So not clear what you are actually asking here. You say you want to delete soemthing but you show us a SELECT that fails?
    – RiggsFolly
    Sep 11, 2020 at 16:04
  • Hi Riggs. Selects are just for example what kind of error is this. I have around 50 delete statements like this: DELETE from mpanel.alias where alias_created < (SELECT CAST(DATE_SUB(NOW(),INTERVAL 2 YEAR) AS DATE)); with different databases, tables and columns, but error is still the same. Sep 11, 2020 at 16:18

3 Answers 3

35

You need to click on "Execute Script" option on DBeaver

enter image description here

If you click the play button, It will show you that error.

5
  • Thanks for reply, but the point is that there is no such option in Pentaho (as I mentioned in post - I need to execute it in Pentaho on "Execute SQL script" where I get same error). Sep 11, 2020 at 16:13
  • I think it should be something similar, look at the documentation of pentaho, it requires precisely that lines must be separated by semicolon., maybe is just to choose the right option, or maybe you have a selected option like "Execute as a single statement" help.pentaho.com/Documentation/8.2/Products/Data_Integration/… Sep 11, 2020 at 16:19
  • No, any option is selected (but I tried everything - just to be sure). My query is around 50 deletes, all of them finished with semicolon. Sep 11, 2020 at 16:27
  • Not sure, but maybe is possible to putthe instruction "DELIMITER ; " at the beginning of the script to force it, Just trying to give some ideas. Sep 11, 2020 at 16:30
  • Yeah, tried this as well. I also tried with different character ('$' and '$$') just to make sure, but didn't help. Anyway thanks for your time. Sep 11, 2020 at 16:33
19

If you is using Dbeaver you can select you script and press ALT+X

wrong and correct way below

enter image description here

1
  • 1
    been looking for this for a while, thanks Oct 28, 2021 at 12:32
1

there must be no spaces before delimiter keyword (dbeaver bug I think)

2
  • this is not an answer on the question
    – Beso
    Dec 1, 2021 at 5:57
  • if you remove spaces before delimiter keyword it works, I think this is an answer Dec 2, 2021 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.