Basic SQL Commands


  SQL commands are fundamental for interacting with databases. Below are some of the basic commands that will allow you to efficiently manipulate and query data.


Basic Syntax


SQL syntax may vary slightly between different database management systems, but the basic commands are generally consistent. Here are some of the most commonly used commands:


1. SELECT

The syntax for selecting data from a table is:
SELECT [columns] FROM [table] WHERE [condition];


2. INSERT

To insert new records, the syntax is:
INSERT INTO [table] (column1, column2) VALUES (value1, value2);


3. UPDATE

To update existing records, use:
UPDATE [table] SET column1 = value1 WHERE [condition];


4. DELETE

To delete records from a table, the syntax is:
DELETE FROM [table] WHERE [condition];


Purpose of SQL


SQL (Structured Query Language) is a programming language designed to manage and manipulate relational databases. Through SQL, you can perform operations such as:


  • Querying data from a database.
  • Inserting new records.
  • Updating existing records.
  • Deleting records.
  • Creating and modifying database structures.


Exercises



Interactive Test 1: Drag and Drop.

Arrastra en el orden correspondiente.


Arrastra las opciones:

SELECT
edad > 25
WHERE
FROM
clientes
*

Completa el código:

______
______
______
______
______
______

Interactive Test 2: Fill in the Blanks

Rellena los huecos en cada casilla.


SELECT  FROM  WHERE ;

Practical Exercise:


Statement:

  Write the necessary query to display all customers from a table who are under 25 years old.


Datos de Ejemplo

idnameage
1 Jhon 25
2 Anna 30
3 Charles 22
4 Mongomery 35

Resultados:

No Result available.


What is the SQL command to select all records from a table?