What is SQL?
SQL (Structured Query Language) is a language used for handling and manipulating relational databases. It is used to perform queries, updates, inserts, and deletions of data in a database. This language is utilized in a wide variety of database management systems (DBMS).
Previous knowledge required to work with SQL
Before working with sql, we need to know some easy concepts.
What is a database?
A database is a tool that allows for the organized collection of data, making it accessible and manageable. It stores information of any type. To facilitate the management of the database, a Database Management System (DBMS) can be used.
What is a DBMS?
A Database Management System (DBMS) is software used for creating and managing databases. DBMS provides an interface for users to perform queries, updates, inserts, and deletions of data in a much simpler way.
Examples of DBMS
- MySQL
- PostgreSQL
- SQL Server
- Oracle
- SQLite
What is a table?
A table is the basic structure of a relational database. It is a collection of data organized in rows and columns. Each row represents a record and each column represents a field.
Basic SQL commands
SELECT
The SELECT command is used to retrieve data from a database.
SELECT column1, column2, ...
FROM table_name;
Also, you can select all fields from a table with the asterisk (*)
SELECT * FROM table_name;
WHERE
The WHERE command is used to filter records.
SELECT column1, column2, ...
FROM table_name
WHERE condition;
The conditions can be of any type, such as equality, inequality, greater than, less than, etc.
ORDER BY
The ORDER BY command is used to sort records.
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
INSERT INTO
The INSERT INTO command is used to insert new records into a table.
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
UPDATE
The UPDATE command is used to update existing records in a table.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
This command will update the value of the specified column in the records that meet the given condition.
DELETE
The DELETE command is uses to delete records from a table.
DELETE FROM table_name
WHERE condition;
Important clarification
It is essential to note that the DELETE command will delete all records from the table if a condition is not specified.
Conclusión
This is just the beginning of SQL, there is much more to learn. If you are interested in learning more about SQL, I recommend that you continue researching and practicing.
Go home