News & UpdatesProgrammingWeb programming Store My Projects
Links
Affiliates

SQL Tutorial – 02 – Using SQL

To follow along in this tutorial you can install MySQL Community Server for free as your database management system. The included MySQL Query Browser can be used to communicate with it. A graphical user interface such as this can of course edit databases without writing any SQL, but for practical applications of SQL such a tool wouldn’t be sufficient. Instead, it’s more common to embed SQL inside of other programming languages, such as C# or Java, or inside of server side scripting languages, such as ASP or PHP.

SQL statements

The SQL statements use a very English-like syntax and are meant to be easy to use and understand. The statements are not case sensitive. Commonly, SQL keywords are written with capital letters and names with lower case letters. This casing will be used throughout this tutorial to help differentiate SQL keywords from arbitrarily chosen names. The standard way to separate SQL statements is using semi colon. Some database systems also require a semi colon to end a statement.

CREATE DATABASE mydatabase;

Comments

Whitespace characters are generally ignored in SQL, so you can format the statements anyway you want. For single-line comments SQL uses double dash (–). Some extensions like MySQL also support C style multi-line comments (/* */).

-- Single-line comment
/* Multi-line 
   comment */
Recommended additional reading:
Sams - Teach Yourself SQL in 10 Minutes