
For an instructor lead, in-depth look at learning SQL click below.
The world of data is expanding at an incredible pace, and at the center of this world, SQL (Structured Query Language) emerges as a key skill that every data enthusiast must possess. No matter whether you are an analyst, IT professional, data scientist, or coming from any other domain, learning SQL will always assist you. With SQL, you can organize, manipulate, and retrieve data from a database.
This blog post will introduce you to the basics of SQL and help you quickly grasp the fundamentals. So, let’s jump right in!
1. What is SQL?
SQL stands for Structured Query Language. As the name suggests, it is a language used to interact with a database. In SQL, we create, delete, fetch rows, and modify rows etc. SQL is a standard language that allows you to perform various tasks with data, analyze it and make useful business decisions.
Example
1 2 3 |
CREATE DATABASE testDB; |
This SQL command will create a new database named “testDB”. SQL code examples are case-insensitive.
2. SQL Tables
A table in SQL consists of rows and columns. It’s similar to a spreadsheet. Each row represents a different record or entity; each column represents a different field or attribute of that entity.
Example
1 2 3 4 5 6 7 8 9 |
CREATE TABLE Employees ( EmployeeID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ); |
This command will create a new table named “Employees” with five columns: EmployeeID, LastName, FirstName, Address, and City.
3. Basic SQL commands
There are several SQL commands you can use to interact with data. But to start with, you should learn the four most basic operations, often referred to by the acronym CRUD:
- Create – adds new data
- Read – reads the data
- Update – modifies the data
- Delete – removes the data
Create
You use the INSERT INTO statement to add new data to a table:
1 2 3 4 |
INSERT INTO Employees (EmployeeID, LastName, FirstName, Address, City) VALUES (1, 'Lane', 'John', '1234 Mockingbird Lane', 'Anytown'); |
Read
You use the SELECT statement to read the data:
1 2 3 |
SELECT * FROM Employees; |
Update
You use the UPDATE statement to modify the data:
1 2 3 4 5 |
UPDATE Employees SET Address = '4321 Serpentine Road' WHERE EmployeeID = 1; |
Delete
You use the DELETE statement to remove data:
1 2 3 4 |
DELETE FROM Employees WHERE EmployeeID = 1; |
Conclusion
That’s it for this crash course on SQL for beginners! On a concluding note, remember that the skill to turn raw data into insightful, actionable information is invaluable in today’s world – and SQL is your tool to do just that. Stay tuned for more on this topic. Happy querying!