SQL
SQL
SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving
data stored in relational database.
SQL Commands
SQL commands are instructions. It is used to communicate with the database. It is also used to perform
specific tasks, functions, and queries of data.
There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
DDL changes the structure of the table like creating a table, deleting a table (drop), altering a table,
etc.
CREATE
Syntax
);
);
DROP:
It is used to remove a table definition and all the data, indexes, triggers, constraints etc..
Syntax
Example
ALTER:
It is used to alter the structure of the database. This change could be either to modify the
characteristics of an existing attribute or probably to add a new attribute.
EXAMPLE:
EXAMPLE:
TRUNCATE:
It is used to delete all the rows from the table and free the space containing the table.
Syntax:
Example:
DML commands are used to modify the database. It is responsible for all form of changes in the
database.
INSERT:
The INSERT statement is a SQL query. It is used to insert data into the row of a table.
Syntax:
Example:
UPDATE:
This command is used to update or modify the value of a column in the table.
Syntax:
Example:
UPDATE students
SET User_Name = 'Sonoo' 3
WHERE Student_Id = '3