Select Statement  «Prev  Next»

Lesson 5 How do SQL dialects differ?
Objective Understand the Variations in SQL Dialects

SQL Dialect Variations

SQL capitalization is generally not mandated by the syntax of SQL itself. Both keywords and identifiers (such as table names and column names) in SQL can be written in either upper or lower case. This is true across the vast majority of SQL dialects, including MySQL, PostgreSQL, SQLite, Oracle SQL, and MS SQL Server. The SQL Standard does not enforce a particular case for keywords or identifiers.
However, it's important to note that there are certain dialect-specific behaviors and conventions related to capitalization.
  1. Case sensitivity of identifiers: While SQL keywords are case-insensitive in all SQL dialects, the case sensitivity of identifiers depends on the SQL dialect and sometimes on the specific configuration of the database management system. For instance, by default, identifiers in PostgreSQL are case-insensitive, but if quoted, they become case-sensitive. MySQL, on the other hand, is case-insensitive for identifiers by default, even when they are quoted, but the case sensitivity can depend on the underlying operating system's file system when dealing with table names.
  2. Convention: It's common practice to write SQL keywords in uppercase and identifiers in lowercase, to distinguish between the two. This practice is often adhered to regardless of the specific SQL dialect, as it improves the readability of the SQL code.
  3. Delimited Identifiers: SQL dialects have different ways to handle case sensitivity and special characters in identifiers. Delimited identifiers (also known as quoted identifiers) are enclosed in quotes and are case-sensitive in most SQL dialects. For instance, "myTable" and "MyTable" would be different identifiers. The use of delimited identifiers and their interaction with case sensitivity can vary between SQL dialects.

It is advisable to familiarize oneself with the specific behaviors and conventions of the SQL dialect being used, and to adopt a consistent style of capitalization in SQL code to enhance its readability and maintainability. Although the SQL Standard does not enforce a particular capitalization style, following common practices and understanding dialect-specific behaviors can lead to more robust SQL code.

Different Versions of SQL

Versions of SQL differ somewhat from platform to platform to support specific features offered by a given database engine.
For example, in one database environment, you might reference a column value by adding a colon before the name of the column. In another, you might not need the colon. In addition, different database capabilities can help you determine the best approach to submitting your query.Although you will not learn about many of the advanced features in this course, it is important to understand that you will need to do some basic research as you start working with your selected database engine. You will need to determine SQL Capitalization.

SQL typically does not care about the capitalization in your queries. Capitalization has been provided throughout this course to help make the content more readable. If you find that you have spelled everything in your query correctly but it still returns no results or an error message indicating it cannot find what you are looking for, check with your database administrator and see if the database is set up to be case-sensitive.

Procedural Extensions

SQL is designed for a specific purpose: to query data contained in a relational database. SQL is a set-based, declarative query language, not an imperative language like C or BASIC. However, there are extensions to Standard SQL which add procedural programming language functionality, such as control-of-flow constructs.
These include:

The following table describes 1) Source, 2) Common Name, and 3) Full name
The following table describes 1) Source, 2) Common Name, and 3) Full name
In addition to the standard SQL/PSM extensions and proprietary SQL extensions, procedural and object-oriented programmability is available on many SQL platforms via DBMS integration with other languages. The SQL standard defines SQL/JRT extensions (SQL Routines and Types for the Java Programming Language) to support Java code in SQL databases. SQL Server 2005 uses the SQLCLR (SQL Server Common Language Runtime) to host managed .NET assemblies in the database, while prior versions of SQL Server were restricted to using unmanaged extended stored procedures that were primarily written in C. PostgreSQL allows functions to be written in a wide variety of languages including Perl, Python, Tcl, and C In the next lesson, the database will be implemented.

SQL Approaches - Quiz

Take this quick quiz to determine how well you understand the basics of SQL before moving on.
SQL Approaches - Quiz

Database Design for Mere Mortals