03_Common SQL Commands
03_Common SQL Commands
main commands in SQL. SQL is the most widely used database query
language. It is designed for retrieving and managing data in a relational
database. SQL can be used to perform different types of operations in the
database such as accessing data, describing data, manipulating data and
setting users roles and privileges (permissions).
Here you will learn about the main commands used in SQL. At a later stage
you will explore relevant examples of how to use these commands with a
detailed explanation of the SQL syntax for key operations such as to create,
insert, update and delete data in the database.
The SQL Commands are grouped into four categories known as DDL, DML,
DCL and TCL depending on their functionality, namely the type of operation
they’re used to perform. Let’s explore these commands in greater detail.
CREATE Command
DROP Command
ALTER Command
Purpose: To change the structure of the tables in the database such as changing
the name of a table, adding a primary key to a table, or adding or deleting a
column in a table.
TRUNCATE Command
Purpose: To remove all records from a table, which will empty the table but not
delete the table itself.
COMMENT Command
SELECT Command
INSERT Command
Purpose: To add records of data into an existing table. Syntax to insert data into
three columns in a table:
UPDATE Command
DELETE Command
GRANT Command to provide the user of the database with the privileges
required to allow users to access and manipulate the database.
COMMIT Command to save all the work you have already done in the database.