1

I am starting to learn SQL using MySQL and I got my hands on book "SQL for MySQL Developers: A Comprehensive Tutorial and Reference".

Why the author doesn't place semicolons ; at the end of the statements?

Can you form legal statement in MySQL without using semicolon?

Here is an example pulled right from the book (p.45) CREATE DATABASE TENNIS. Of course, MySQL shell responds by ->.

newprint
  • 6,936
  • 13
  • 67
  • 109
  • Why do you use more than one question mark???????????? – tckmn Feb 08 '13 at 01:55
  • 1
    you need semicolon to put more statements in one line – lelloman Feb 08 '13 at 02:01
  • even a one line doesn't work I think, at least quering via console i usually forget the semicolon and the query doens't go, but in php yes as far as I can remember – lelloman Feb 08 '13 at 02:03
  • give an example please? The only situation I can see this is within stored procedures. – Sebas Feb 08 '13 at 02:06
  • 3
    Hmm, this question appears to be related to the *command line interface* and limitations of when it will/will not send a request. The `;` is *not required* on the server for a single command, but command-line clients typically only send a command after a `;` - this makes sense from a CLI where there is no "run command" (e.g. F5) action, aside from "pressing enter", as SQL commands can naturally continue onto multiple lines. –  Feb 08 '13 at 02:10
  • You might want to read [MySQL - 3.2. Entering Queries](http://dev.mysql.com/doc/refman/5.0/en/entering-queries.html) and [this SO question](http://stackoverflow.com/q/710683/913097). – inhan Feb 08 '13 at 02:17

1 Answers1

1

Many flavors and applications of SQL require a semi-colon at the end. A few do not.

Smandoli
  • 6,919
  • 3
  • 49
  • 83
  • 1
    This is a duplicate of http://stackoverflow.com/questions/710683/when-should-i-use-semicolons-in-sql-server – Smandoli Feb 08 '13 at 02:16
  • 1
    I thought the same but that question is about the SQL Server whereas this one is particularly about MySQL so I posted a link to MySQL official documentation instead in the comments. – inhan Feb 08 '13 at 02:20