
For an instructor lead, in-depth look at learning SQL click below.
Welcome to SQL 101! If you’re new to databases, you’re in the right place. SQL, or Structured Query Language, is a language designed specifically for interacting with databases. Let’s start this journey!
What is a Database?
A database is essentially an organized collection of data. Data in a relational database is stored in tables, and it can be accessed or reassembled in different ways to suit different needs.
What is SQL?
SQL (Structured Query Language) is a programming language that is used to manage and manipulate databases. Professionals use SQL to edit and query data that is stored in a relational database.
First Steps in SQL
Before you dive into writing SQL queries, it’s important to first understand how the databases are structured. A simple database table often has the following architecture:
|
1 2 3 4 5 6 7 |
CREATE TABLE Employees ( ID int, Name varchar(255), Age int, Address varchar(255)); |
In SQL, you can retrieve data using a SELECT statement. If you want to retrieve all employees from the Employees table, you would use:
|
1 2 3 |
SELECT * FROM Employees; |
Where Clause
The WHERE clause in SQL is used to filter records that fulfill a specified condition. Here’s an example:
|
1 2 3 4 |
SELECT * FROM Employees WHERE Age > 30; |
This SQL statement selects all employees older than 30.
Insert, Update, and Delete
INSERT is used to insert data into a table, UPDATE is used to update existing data, and DELETE is used to delete data. Here’s how you’d use these commands:
|
1 2 3 4 5 6 7 8 9 10 11 |
INSERT INTO Employees (ID, Name, Age, Address) VALUES (1, 'John Doe', 35, '12th Avenue'); UPDATE Employees SET address= '23rd Avenue' WHERE name= 'John Doe'; DELETE FROM Employees WHERE name= 'John Doe'; |
Conclusion
Congratulations on writing your first SQL syntax! SQL 101 is your foundation to understanding SQL. There’s more to learn, so continue to practice and experiment with different queries and commands. Good luck!
|
1 |
To be continued... |
