
For an instructor lead, in-depth look at learning SQL click below.
SQL, or Structured Query Language, is a programming language specifically designed for managing data held in a relational database management system. As a beginner aiming at understanding SQL fundamentals, this article is for you. We will walk through the very beginnings of this language and provide examples to give you a basic understanding.
What is SQL?
SQL stands for Structured Query Language. It is a standard programming language for relational databases. Relational databases are a type of database that organizes data into tables, and SQL is used to manage and manipulate that data.
First Steps in SQL
The very first step in SQL is to understand the basic commands. The most fundamental commands of SQL are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP.
CREATE Statement
|
1 2 3 4 5 6 7 8 9 |
CREATE TABLE Employees ( ID int, Name varchar(255), Age int, Address varchar(255), Salary real ); |
The above command is the CREATE statement. This command is used to create a new table in the database. In this example, we are creating a new table called ‘Employees’ with five columns: ID, Name, Age, Address, and Salary.
INSERT Statement
|
1 2 3 4 |
INSERT INTO Employees (ID, Name, Age, Address, Salary) VALUES (1, 'John', 29, '123 Main St', 50000.00); |
The INSERT statement is used to insert new records into a table. In this example, we are inserting a new record into our Employees table.
SELECT Statement
|
1 2 3 |
SELECT * FROM Employees; |
The SELECT statement is used to select data from a database. In the previous example, we are selecting all records from the Employees table.
UPDATE Statement
|
1 2 3 4 5 |
UPDATE Employees SET Salary = 55000.00 WHERE ID = 1; |
The UPDATE statement is used to modify the existing records in a table. In this example, we are updating the salary of the employee with ID 1.
DELETE Statement
|
1 2 3 |
DELETE FROM Employees WHERE ID = 1; |
The DELETE statement is used to delete existing records in a table. In this example, we are deleting the record of the employee with ID 1.
The understanding of SQL goes beyond just these basic commands. There are other advanced operations in SQL such as joining tables, using the WHERE clause to filter records, ordering and grouping data etc. However, with these fundamental commands, you are set on the right path to delve deeper into the richness of SQL.
Conclusion
Remember, this tutorial is a primer to get you started. SQL is a vast field with numerous advanced functionalities. The more you practice and use SQL, the more you will understand and appreciate its power in dealing with large data sets and databases. Happy Learning!
