SQL - Syntax - (Speaking SQL)
Syntax, by definition, means the study of linguistic rules and patterns. Every programming language, including SQL, must follow a unique set of guidelines termed syntax. Punctuation, spaces, mathematical operators, and special characters have special meaning when used inside of SQL commands and query statements. For example, each and every SQL command will end with a semi colon (;).Let's now take a look at a very simple SQL command that will be used in just about every example contained in this tutorial from here on out.
Sample SQL Command:
use mydatabase;
SQL - Syntax: Capitalization and Spacing
In some programming languages, capitalizing commands or excessive spacing may or may not cause syntax code errors and cause the command to fail. SQL syntax is very loose when it comes to capitalization and spacing, allowing a lot of room for the developer to decide on his/her own preference in regards to capitalization and spacing.Let's rewrite the same SQL command from the previous example and take advantage of SQL's loose syntax characteristics.
Sample SQL Command:
USE mydatabase;
SQL - Syntax: Building good habits
While coding in any language, it is important to develop good, consistent habits and maintain clean code. Clean code allows another SQL developer to step right in where you have left off without missing a beat. A developer with diligent coding habits will prevent many syntax errors before executing his/her scripts and also will be able to detect possibly syntax problems before they cause problems in a SQL Command.Good habits include:
- Consitency
- Clean and Concise
- Use of Comments (more on this later)
- Scalability
0 comments:
Post a Comment