Hello! Welcome to my day 8 of 100 days of code! Today, we are going to be learning about SQL manipulation.

Photo by Clément H on Unsplash

First, what is SQL?

SQL, also known as Structured Query Language, is a programming language made to manage stored data in relational databases. SQL uses simple, declarative statements to run. These simple statements help maintain the integrity of databases and help keep the data secure and accurate.

For example, if we wanted to get all the data from the cats database, we would run something like this:

This would return a table from a relational database.

What is a relational database?

A relational database is a database that organizes information into one or more tables. A table is a collection of data sorted into columns and rows. The table here is cats. A column is a set of data values, so cats would probably have a column id, name, and age. A row is a single record in the table.

All data stored in a relational database has a specific data type. Here is a list of the common data types:

What is a statement? Clauses? Parameters?

A statement is text the database recognizes as a valid command. It's important to understand they will always end in a semicolon.

Let’s break down the statement below:

Now that we have the basics out of the way let’s start learning about different clauses.

CREATE

Create statements allows us to create new tables. Let’s go over the example below:

INSERT

The insert statement inserts a new row into the table. Let’s break down the example below:

SELECT

The select statement is used to get data from the database. Let’s look at an example:

ALTER

The ALTER TABLE statement adds a new column to the table. Take a look at the example below:

UPDATE

The UPDATE statement edits a row in a table. You would use this if you wanted to update existing data. For example:

DELETE

The DELETE FROM statement deletes one or more rows from a table. Let's take a look at this clause in action:

CONSTRAINTS

Constraints add information about how a column can be used and are invoked after specifying the data type for a column. If you arent getting it, don’t worry. We are going to break about the example below:

That wraps up our SQL manipulation crash course! Thanks for reading!

Hi there! Im a photographer thats pursuing my dreaming of become a software engineer. Join me while I attempt the #100daysofcode challenge!