SQL is a text-based command language for database work. Each SQL statement instructs the database server to perform some task, such as creating a new table or deleting a row. SQL statements begin with one or two keywords that identify the action to be performed, and end with a semicolon (“;”).
Other clauses and expressions can appear in between. Statements can span lines, and all whitespace is equivalent. SQL is case-insensitive, except for character strings, and identifiers written inside double-quotation marks.
You can annotate your code with comments, which will be ignored by the system. Both line and block comments are supported:
-- This is a single-line comment.
/* This is
The code you write has no effect until you run it. For normal development and testing, you should run only the current statement (the one nearest the text cursor), by typing Ctrl+Enter. You can also execute a group of statements by selecting them and pressing the F5 key. To run the entire file as a script, press F5 with nothing selected.
NOTE: The code you see in the editor in front of you does not necessarily match what is in the database. Use the Database Navigator panel at the left to see the current state of the database (remember to right click and refresh to get an updated view)). You should also save a copy of your SQL source code for future reference (and make sure to save often!).
NOTE: when asked to write an SQL script, you must test it thoroughly to ensure that it runs without errors as a batch. Pay particular attention to the order of the statements, and don’t assume that the script will run just because you have tested the statements individually!