
For an instructor lead, in-depth look at learning SQL click below.
SQL, or Structured Query Language, is the standard language for communicating with databases. Whether you’re working with small datasets or large databases housing millions of records, the ability to write SQL queries efficiently and effectively is a crucial skill for anyone in a data-driven role. The purpose of this blog post is to introduce you to SQL and get you started with some essential SQL queries.
What is SQL?
SQL is a domain-specific language designed for managing data stored in a relational database management system (RDBMS) or for stream processing in a relational data stream management system (RDSMS). It is incredibly scalable and is used everywhere from small businesses to giant corporations.
Setting Up Your Database
|
1 2 3 |
CREATE DATABASE testDB; |
In the above SQL code, the CREATE DATABASE statement will create a new database named testDB.
Creating Tables
|
1 2 3 4 5 6 7 8 |
CREATE TABLE Employees ( ID int, Name varchar(255), Birthday date, Salary float ); |
Here, the CREATE TABLE statement creates a new table named Employees in your database, with columns ID, Name, Birthday, and Salary.
Inserting Data
|
1 2 3 4 |
INSERT INTO Employees (ID, Name, Birthday, Salary) VALUES (1, 'John Doe', '1990-01-01', 50000.00); |
In this SQL statement, the INSERT INTO command inserts a new row into the Employees table, adding John Doe as a new employee.
Selecting Data
|
1 2 3 |
SELECT * FROM Employees; |
This is probably the most used SQL query. The SELECT statement retrieves data from the Employees table. The asterisk (*) selects all columns from the table.
Updating Data
|
1 2 3 4 5 |
UPDATE Employees SET Salary = 60000.00 WHERE ID = 1; |
The UPDATE statement changes the data in the Employees table. In this case, it updates John Doe’s salary to 60000.00.
Deleting Data
|
1 2 3 4 |
DELETE FROM Employees WHERE ID = 1; |
The DELETE statement removes rows from the Employees table. Here, it removes the employee with ID 1.
Learning SQL opens up new avenues for handling data effectively, and while it may seem challenging at first glance, with practice and usage these commands can become second nature. We hope this basic guide helps you get started on your SQL journey!
