Skip to content

Structured Query Language

raccoon database

What is SQL?

SQL is a computer language that was invented in 1986 and has become a standard way that engineers and programmer build and maintain database applications. It is designed to allow us to create very precise and very efficient commands that the machine understands. These commands can address relatively simple operations, like:

SELECT * FROM originators;

Which will return every row from a table called originators, as well as very complex commands that allow you to find records in your database according to very specific and complicated criteria.

A slightly more complex SQL command might look like this:

SELECT * FROM words WHERE root='cgʷ';

This time the command will only return the rows in the words table in which the root column contains cgʷ.

What does SQL do?

SQL statements can do a variety of things. They usually begin with a main command (SELECT) in the example above, followed by some set of criteria (* in the example above is a selector that asks for everything), followed by one or more tables to include (originators in the first example above.) The statements might also contain various modifiers, like WHERE in the second example above. The commands end in semicolon ; and nobody knows why.

Some of the main SQL commands you'll encounter are:

  • SELECT, which returns all matching rows for you to view;
  • INSERT INTO, which add one or more records into one or more tables;
  • UPDATE, which modifies information in one or more tables;
  • DELETE, which removes information from one or more tables (so be careful with this one!);
  • CREATE TABLE and CREATE DATABASE, which do what they say they are gonna do;
  • ALTER TABLE and ALTER DATABASE, which are used to change the structure of a table or database;
  • DROP TABLE and DROP DATABASE, which are used to remove (delete) tables and databases (so be careful with these two also!)

Important modifiers to know about:

  • WHERE introduces a pattern that must match in order for the command to apply;
  • ORDER BY tells the computer how to order the results;
  • COUNT tells the computer to tell you how many records match your command

There's a lot more, of course, to SQL, and we'll give you all the commands you need to know for this workshop here in our materials.

If you'd like to explore more SQL, W3Schools has a very nice tutorial we'd recommend as a starter kit

How'd we do?

Do you feel like you have a sense for what SQL is and what it does? If so, great! If not, we hope you'll ask more questions.

You can contact John, Gus, or Amy and we'll do the best we can to help!

At this point, you might want to go back to our our Day 1 materials 🚀 or to the CoLang Workshop Homepage 🚀