SQL (Structured Query Language) is a standardized programming language designed for managing data in relational database management systems (RDBMS). It is used to perform various operations on data, including:
SELECT
StatementThe SELECT
statement is used to retrieve data from a database.
SELECT column1, column2, ...
FROM table_name;
Example:
SELECT name, age
FROM customers;
This statement retrieves the name
and age
columns from the customers
table.
WHERE
ClauseThe WHERE
clause is used to filter data based on specific conditions.
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Example:
SELECT name, age
FROM customers
WHERE age > 25;
This statement retrieves the name
and age
columns from the customers
table where the age
is greater than 25.
INSERT
StatementThe INSERT
statement is used to add new records to a table.
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Example:
INSERT INTO customers (name, age, city)
VALUES ('John Doe', 30, 'New York');
This statement inserts a new record into the customers
table with the specified values for name
, age
, and city
.
UPDATE
StatementThe UPDATE
statement is used to modify existing records in a table.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Example:
UPDATE customers
SET age = 31
WHERE name = 'John Doe';
This statement updates the age
column to 31 for the record where name
is 'John Doe'.
DELETE
StatementThe DELETE
statement is used to remove records from a table.
DELETE FROM table_name
WHERE condition;
Example:
DELETE FROM customers
WHERE age < 18;
This statement deletes all records from the customers
table where the age
is less than 18.
This is a basic introduction to SQL. There are many other commands and features available in SQL that are beyond the scope of this tutorial. You can learn more about SQL by exploring the following resources: