June 8, 2019

The Creators of SQL: Donald D. Chamberlin, and Raymond F. Boyce designed SQL while working at IBM to manipulate and retrieve data that was stored in IBM’s original sudo-relational database management system, System R, which was developed at IBM’s San Jose Research Laboratory in the 1970s.

Reasons To Use SQL: SQL (Structured Query Language) allows you to easily query databases for use in your data projects.

Though there are many variants on DBMS (Database Management System), knowing the basics can allow you to interact with databases regardless of what software you eventually use.

Being able to manipulate queries results in far more powerful results than simply using Excel filters on a dataset in a spreadsheet.

The Basics Of SQL: I’ve been learning SQL as a result of my job, but also on the side as well to include databases for the fun side projects I have. As a result, I’ve been able to get a bit more familiar with the basics of how SQL works, so I’d love to impart some of the basics in this post. How To Use Sqlite3 In Linux Bash Shell

Starting Sqlite3 Using An Existing Database Here’s the basic syntax on how to open up any Sqlite database using the Linux Bash Shell. First, start up a terminal in your Linux OS, and run the following command after installing Sqlite3 to open up an any database you’d like. The syntax is: sqlite3 (name of database).

Here’s an example:

sqlite3 example.db

Running A .sql Script After Loading A SQL Database Now that we’ve gotten the database loaded, use the ‘.read’ command to open up any SQL script that you currently have present in the same directory. For example, I’m going to load an example script called ’example.sql’:

.read example.sql

Your First SQL Select Query Now that we’ve discussed how to open up Sqlite3 with the Bash shell, let’s put this to good use by creating our first query. In this example, I am using the Sqlite database provided by the book, “SamsTeachYourself SQL in 10 Minutes”, which can be found here:

Let’s begin by opening up the ’tysql.sqlite’ database on the Linux Bash Shell in Sqlite3, and then query it directly:

sqlite3 tysql.sql

Now, let’s use the ‘SELECT’ keyword to ‘select’ some of the data present. More specifically, let’s just select all of the data present by using the ‘*’ or ‘Wildcard’ character in order to select all of it with the following SQL statement. Also, we need to specify what table it is from using the ‘FROM’ keyword, which we’ll make sure to tell SQL to grab data from the ‘Products’ table.

SELECT * FROM Products;

Our result would look like the following: <img width=“85%” height=“100%” src=“images/SelectStatementResult.jpg”/>

Voilah! You now know how to do the most basic SQL select statement of all using the ‘*’ wildcard character.

Sources