Informatics Practices · Ch 7 — Introduction to Structured Query Language (SQL)
Installing MySQL
Installing MySQL
Before any SQL can be written, the software that understands it must be on your machine. MySQL is an open source RDBMS, which means it can be downloaded freely — the official website for this is https://dev.mysql.com/downloads.
Installation alone is not enough: after installing MySQL, the MySQL service has to be started. Once the service is running and you open the client, the appearance of the prompt shown below signals that MySQL is ready to accept SQL statements from you (this is the MySQL shell seen in Figure 8.1):
mysql>
From this point, everything you type at the prompt is an SQL statement, and a few rules of etiquette govern how those statements are written in MySQL:
- SQL is case insensitive. To SQL, name and NAME are the same word, so capitalisation never changes the meaning of a statement.
- Every SQL statement must end with a semicolon (;). The semicolon is what tells MySQL "the statement is complete — execute it now."
- Long statements can be spread over several lines. The trick is simply to not type the semicolon at the end of the first line; pressing Enter then continues the statement on the next line. MySQL acknowledges this by changing the prompt from mysql> to ->, which is its way of indicating that the statement is still being continued. You keep typing across as many lines as needed, and after the last line you finally type the semicolon and press Enter — only then does the statement run. …