
For an instructor lead, in-depth look at learning SQL click below.
Welcome to this beginner’s tutorial on SQL. Structured Query Language, or SQL, is the standard language for dealing with Relational Databases. SQL can be used to insert, search, update, and delete database records. It doesn’t mean SQL cannot do things beyond that. In fact, SQL is one of the most powerful tools available to you for communicating with your database.
What Is SQL?
SQL (pronounced ‘sequel’) stands for Structured Query Language, and it provides a consistent interface to a relational database. This means that it is a standard way to request (or query) information from a database, which it will then return to you.
Getting Started with SQL
Creating a Database
Let’s imagine that you own a company and want to store details about your employees in a database. Here is how you would create such a database:
1 2 3 |
CREATE DATABASE EmployeeDB; |
Creating a Table
Inside a database, we can create tables. For example, let’s create a table named “Employees” with three columns: ID, Name, and Position.
1 2 3 4 5 6 7 |
CREATE TABLE Employees( ID INT PRIMARY KEY, Name VARCHAR(20), Position VARCHAR(20) ); |
Inserting Data Into a Table
Now let’s add some data to our table.
1 2 3 4 5 6 |
INSERT INTO Employees(ID, Name, Position) VALUES(1, 'John', 'Manager'), (2, 'Jane', 'HR'), (3, 'Heidi', 'Sales'); |
Selecting Data From a Table
We can retrieve this data with a SELECT statement:
1 2 3 |
SELECT * FROM Employees; |
Where to Go from Here?
Congratulations on taking your first steps with SQL! There’s much more to learn, such as how to update data, delete data, filter records, and sort data. SQL is a powerful and versatile tool, and becoming proficient at it will open up many doors in your programming or data science career!
Best of luck, and happy querying!