SQL Languages - a guide

by Jack Arnaud

SQL, or Structured Query Language, is a perfect example of the power of simplicity. First designed by Donald D. Chamberlin and Raymond F. Boyce in 1974, it's longevity is highly unusual for a coding language (only Fortran and C can claim a longer lifespans). This longevity can be credited to the benefits of relational databases, as an efficient storage method with a simple language to extract information, and it's competitive performance regardless of the scale of deployment.

The language has changed and evolved since it's inception, as various database softwares added functionality in different ways. This has resulted in different "dialects" of SQL, as different companies develop slightly different syntaxes (T-SQL for SQL server, PL/Pg SQL for PostgreSQL, PL/SQL for Oracle).

Although this can be confusing, most SQL database providers offer similar "languages", which allows for developers and the users to interact with the database in different ways. Let's have a look at these languages.

SQL Languages

SQL languages allow for different types of interactions with the database. Some users will want to "define" the database (adjust the structure of a database), "manipulate" the data (change the data contained) or "control" who can access what (change the privileges of certain users), while others may simply want to "query" the database (extract a section of the data). Here's how they would do that.

Helpful note - all uppercase words are commands in their respective languages.

DDL (Data Definition Language)

This language allows you to CREATE, ALTER and DROP tables, the building blocks of SQL. Without this, there would be no structure to a database. Additional commands are TRUNCATE, COMMENT and RENAME.

DML (Data Manipulation Language)

This language allows you to INSERT, UPDATE and DELETE data into tables, populating the tables created with the right data. Additional commands are LOCK, CALL and EXPLAIN PLAN.

TCL (Transaction Control Language)

This language allows you to group together queries, before you COMMIT them at the same time. You can also undo, or ROLLBACK any queries that are unsatisfactory. Additional commands are SAVEPOINT and SET TRANSACTION.

DCL (Data Control Language)

This language is another that is useful to administrators. It allows the administrator to GRANT and REVOKE user permissions within the dataset. This is useful to prevent users accessing information that may be sensitive to specific users.

DQL (Data Query Language)

This is the language that you use to query a database. You can SELECT any values FROM a given database. You can also add conditional queries, using the WHERE command. This is the part of the language most often altered by database providers, allowing for (among other things) more complex queries and calculations within queries.