I want to learn SQL on my Mac. What's the best way to get started?

If you're interested in web design or programming, then sooner or later you're going to encounter SQL (Structured Query Language). SQL is a relatively simple programming and coding language used to manage data held in a database (or an RDBMS, or relational database management system, to give it its full and fancy name).

Read next: Complete guide to coding and programming on a Mac

Don't be put off by the dryness of data management in SQL, or the weirdness of the language. A lot of disgruntled programmers curse SQL, but it's essential that you learn. SQL is behind just about every major bank, hospital and government system, not to mention every website you use.

It's also a lot easier to learn SQL than you might first imagine. SQL came out in 1974 and hasn't taken on board a lot of modern coding advances, so it doesn't have object-orientated structures, or trees, or nested operations. You just learn to create, read, update and delete data from tables, a process known as CRUD.

Let's get started.

See also:

How to set up and learn SQL in OS X: Choosing a version to install

There are several different SQL installations available, but these three are the main ones people use:

  • SQLite. This library is small and gets embedded inside the application you're making. This saves you from having to communicate through ports, and its incredibly fast. Its feature set is limited compared to other services.
  • MySQL. This is the biggest name around, and is far more feature-rich than SQLite. It's easy to install, and there are lots of tutorials and help available.
  • PostgreSQL. This is the advanced option, and definitely not where you want to be as a beginner. It's powerful and highly extensible, although it's not as popular as MySQL.

If you're a beginner then go with SQLite. It's easier to install and learn, and you can go a long way learning just the SQL basics. You can always migrate to MySQL if you find that SQL is a skillset you need.

How to install SQLite in OS X

Installing SQLite

Installing SQLite on your Mac is pretty straightforward. Just follow these steps:

Head over to SQlite.org and download the C source code file, named sqlite-autoconf-3130000.tar.gz or similar, from the SQLite download page.

Open Terminal and enter the following commands:

  1. cd Downloads/
  2. tar -xf sqlite-autoconf-3130000.tar.gz [or whatever the name of the C source code file is]
  3. cd sqlite-autoconf-3130000
  4. ./configure --prefix=/usr/local
  5. make
  6. make install

You can now test the SQLite installation by entering sqlite3 in Terminal. You should see:

SQLite version 3.13.0 2016-04-08 15:09:49 [or similar]

Enter ".help" for usage hints.

Connected to a transient in-memory database.

Use ".open FILENAME" to reopen on a persistent database.


SQLite running on a Mac

How to learn SQL in OS X

Once you've got SQLite set up in Mac OS X, it's time to start learning how to use it. Forutnately there are no shortage of courses and books out there that will help you learn. Here are some of the best places to get started: