Sql Intro And Installation Readme

Overview

We'll get started with SQL by installing and trying out SQLite.

Objectives

  1. Check to see if SQLite is installed on your computer via a terminal command
  2. Install SQLite on your computer
  3. Create and open a database file and table
  4. End all SQL commands using proper semicolon notation
  5. Exit out of SQLite using the .quit command

Installing SQL

If you are using the Learn IDE, you don't need to install anything. We've already done this for you :)

Macs Make It Easy

If you are on OSX version 10.4 or greater, you probably already have SQLite installed. Find out by opening up the terminal and pasting in:

which sqlite3

if you get back

/usr/bin/sqlite3

Then you have a working version of sqlite3 already installed on your system. Thanks Apple! Skip ahead to the 'Trying it out' section below!

If not, then there are a couple of ways you can install SQLite.

Manual Installation Options

Install With Homebrew:

Via a package manager for your operating system. If you are on Mac, Homebrew is the way to go. You can install it by following the brew installation instructions

After installing Homebrew, install sqlite with:

brew install sqlite
Install From Binary

If Homebrew isn't working out for you, you can download one of the pre-compiled binary packages available at the downloads page. Look for your operating system, download and install the appropriate binary.

Trying it out

Okay, let's make sure everything is up and running. In your terminal, type:

sqlite3 test_sqlite.db

This will open a new database file called test_sqlite.db and open it in the sqlite prompt. You should see something like:

SQLite version 3.7.12 2013-03-19 12:42:02
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

You are now looking at the sqlite prompt.

Let's create a database table called "Test Table":

sqlite> create table test_table(id);
sqlite> .quit

You should have created a test_sqlite.db file. Either open up the directory you are working from in finder or type open . into your terminal. You should see that, inside whatever directory you've been working in, you have your test_sqlite.db file.

Top-Tip: All SQL statements that you write in your terminal, inside the sqlite prompt, sqlite3>, must be terminated with a semi-colon ;. If you hit enter without adding a semi-colon to the end of your line, you will be trapped! Don't worry though, just add that ; on the new line and hit enter again. The only command that doesn't require, and in fact doesn't even work with, a ; is the .quit command.

Resources

View this lesson on Learn.co

View SQL Intro and Installation on Learn.co and start learning to code for free.

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us