Search code examples
sqljdbcandroid-sqlite

Is the semicolon necessary in SQL?


Sometimes it works anyway if I forget the ;. But sometimes it doesn't.

And in JDBC and Android SQLite, it seems that I don't need ; at all. I am confused.

When should I use a semicolon?


Solution

  • semicolon indicates end of a statement, so if there are multiple statements then you should use semicolon else it will work fine.

    I generally use semicolon as a practice, it can be useful even when you are running queries on sql client e.g. in Sql Developer using semicolon is very helpful if you have multiple statements on worksheet, as you can simply go to that particular statement and use F9 to execute that, without semicolon this is not possible.