SQL Tutorial
Introduction
SQL (Structured Query Language) is a programming language used to manage and manipulate relational databases. SQL is used to create, modify, and delete database tables, rows, and columns. In this tutorial, we will cover the basics of SQL syntax, examples, outputs, explanations, uses, important points, and summary.
Syntax
The basic syntax of SQL consists of various statements used to interact with a database. Some of the commonly used statements are:
SELECT column1,column2 FROM table_name;
INSERT INTO table_name (column1, column2) VALUES (value1, value2);
UPDATE table_name SET column1 = value1 WHERE column2 = value2;
DELETE FROM table_name WHERE column1 = value;
Example
Consider the following table students
:
id | name | age | gender |
---|---|---|---|
1 | John | 18 | M |
2 | Mary | 20 | F |
3 | Adam | 19 | M |
To select all the columns from the students
table, the SQL query would be:
SELECT * FROM students;
Output
The output of the previous SQL query would be:
id | name | age | gender |
---|---|---|---|
1 | John | 18 | M |
2 | Mary | 20 | F |
3 | Adam | 19 | M |
Explanation
The SQL SELECT
statement is used to retrieve data from a database table. In the above example, we are selecting all the columns from the students
table using the asterisk (*
) wildcard character.
Use
SQL is used to create, modify, and delete database tables, rows, and columns. SQL is also used to retrieve and manipulate data from a database.
Important Points
- SQL is used to manage and manipulate relational databases.
- SQL consists of various statements used to interact with a database.
- The SQL
SELECT
statement is used to retrieve data from a database table. - SQL is used to create, modify, and delete database tables, rows, and columns.
Summary
SQL is a programming language used to manage and manipulate relational databases. SQL consists of various statements used to interact with a database, and the SQL SELECT
statement is used to retrieve data from a database table. SQL is used to create, modify, and delete database tables, rows, and columns.