
For an instructor lead, in-depth look at learning SQL click below.
SQL, or Structured Query Language, is the universal language for managing and querying data in relational database management systems (RDBMS). If you are a beginner looking to equip yourself with SQL skills, this post will serve as a starting point. We’ll focus on the core concepts and provide examples that should get your feet wet in the SQL sea.
What is SQL?
SQL was designed to manipulate and retrieve data stored in relational databases. With SQL, you can create databases, tables, view, stored procedures, and more. It has a standardized syntax and is ANSI and ISO certified. Despite variations in various DBMS like MySQL, MS SQL Server, Oracle, etc., the core SQL commands like SELECT, UPDATE, DELETE, INSERT, WHERE remain the same.
The Basic SQL Commands
The basic SQL Commands are SELECT, INSERT, UPDATE, DELETE, WHERE.
Here are examples of how each of these is used:
Select Statement
1 2 3 |
SELECT * FROM Customers; |
The above command selects all records in the “Customers” table.
Insert Statement
1 2 3 4 |
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'); |
This command inserts a new record into the “Customers” table.
Update Statement
1 2 3 4 5 |
UPDATE Customers SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1; |
This command updates the contact name and city of Customer with ID = 1.
Delete Statement
1 2 3 4 |
DELETE FROM Customers WHERE CustomerName='Cardinal'; |
The command deletes the customer ‘Cardinal’ from the ‘Customers’ table.
Where Clause
1 2 3 4 |
SELECT * FROM Customers WHERE Country='Mexico'; |
The command selects all fields from ‘Customers’ table where country is ‘Mexico’.
Conclusion
SQL is a powerful language that can explore data like no other. With SQL, you can handle bulky and complex data easily. This post should give you a starting point for learning SQL. If you are an aspiring data analyst or scientist, having a strong SQL foundation will help you deal with databases efficiently, thus opening a plethora of new avenues.