0% found this document useful (0 votes)
4 views

SQL Command

SQL, or Structured Query Language, is a standard language for managing data in relational database management systems (RDBMS) such as MySQL and Oracle. It includes four main types of commands: DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and TCL (Transaction Control Language), each serving different purposes for database operations. Key commands include CREATE, SELECT, GRANT, and COMMIT, which allow users to create tables, retrieve data, manage permissions, and save changes, respectively.

Uploaded by

N Md Shakeel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

SQL Command

SQL, or Structured Query Language, is a standard language for managing data in relational database management systems (RDBMS) such as MySQL and Oracle. It includes four main types of commands: DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and TCL (Transaction Control Language), each serving different purposes for database operations. Key commands include CREATE, SELECT, GRANT, and COMMIT, which allow users to create tables, retrieve data, manage permissions, and save changes, respectively.

Uploaded by

N Md Shakeel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

SQL

o SQL stands for Structured Query Language. It is used for


storing and managing data in relational database management
system (RDMS).
o It is a standard language for Relational Database System. It
enables a user to create, read, update and delete relational
databases and tables.
o All the RDBMS like MySQL, Informix, Oracle, MS Access and
SQL Server use SQL as their standard database language.
o SQL allows users to query the database in a number of ways,
using English-like statements.

SQL Languages

the four different types of languages or commands which are widely


used in SQL queries:

1. TCL (Transaction Control Language)


2. DML (Data Manipulation Language)
3. DCL (Data Control Language)
4. DDL (Data Definition Language)

DDL (Data Definition Language)

Data Definition Languages allow users to create, modify, and


destroy the schema of database objects.
We can enter the correct data in the database by applying the
constraints in the DDL languages.

The DDL Languages or commands are categorized into five


commands which are widely used in the SQL queries:

1. CREATE DDL Command


2. ALTER DDL Command
3. DROP DDL Command
4. TRUNCATE DDL Command
5. RENAME DDL Command

Let's discuss each DDL command with syntax and examples.

CREATE Command

This DDL command allows us to create the new table, function,


stored procedure, and other database objects.

Syntax of Create DDL Command to create a new table in the


database:

CREATE TABLE Name_of_Table ( Column1 datatype (Length), Co


lumn2 datatype (Length) …….);

ALTER Command

This DDL command allows us to modify the structure of database


objects.

Syntax of Alter Command to modify the existing table:

ALTER TABLE Name_of_Table ADD Column_Name Datatype (Le


ngth of Column);

DROP Command

This DDL command allows us to remove the table definition and data
from the SQL systems.

Syntax of Drop Command to remove the existing table:

DROP TABLE Name_of_Table;


TRUNCATE Command

This DDL command allows the database users to remove all the
existing records from the table.

Syntax of Truncate Command to delete all records:

TRUNCATE TABLE Name_of_Table;

RENAME Command

This DDL command allows the users to change the name of the
existing table.

Syntax of RENAME Command for changing the table name:

RENAME Old_Table_Name TO New_Table_Name;

DML (Data Manipulation Language)

Data Manipulation languages allow database users to change the


existing data of the tables.

We can use this type of language when we want to access the record,
insert the new record, update the record, and delete the existing values
from the tables.

Following are the four DML Languages or commands used in the


SQL queries:

1. SELECT DML Command


2. INSERT DML Command
3. UPDATE DML Command
4. DELETE DML Command

Let's discuss each DML command with syntax and examples.

SELECT Command
This DML command allows us to access the stored records from the
tables. We can also use the condition in the SELECT command for
accessing the particular rows.

Syntax of SELECT Command:

SELECT * FROM Name_of_Table;


INSERT Command

This DML command allows the database users to insert the new
record or rows in the tables.

Syntax of INSERT Command for inserting the single record:

INSERT INTO Name_of_Table ( Column_1, Column_2, Column_3,


…..) VALUES (Value1_of_Column_1, Values);

UPDATE Command

This DML command allows the database users to change the existing
record or rows in the tables.

Syntax of UPDATE Command for modifying the records:

UPDATE Name_of_Table SET Column_Name = Value WHERE [


Condition ];
DELETE Command

This DML command allows the database users to delete a particular


record or row from the tables.

Syntax of DELETE Command for removing the records:

DELETE FROM Name_of_Table WHERE [ condition ];

DCL (Data Control Language)


Data Control Languages allow DBA to manage the rights and
permissions on the data in the database.

Following are the two DCL Languages or commands used in the SQL
queries:

1. Grant DCL Command


2. Revoke DCL Command

Let's discuss the above two DCL commands one by one with syntax
and examples.

GRANT Command

This DCL command allows the database administrator to give


permissions to the user for retrieving the data.

Syntax of Grant DCL Command:

GRANT Name_of_Privilege ON Object TO User;

REVOKE Command

This DCL command allows the database administrator to remove all


the permissions applied by the GRANT DCL command.

Syntax of REVOKE DCL Command:

REVOKE Name_of_Privilege ON Object FROM User;

TCL (Transaction Control Language)

Transaction Control languages maintain the SQL operations within


the database. It also saves the changes made by the DML commands.

Following are the two TCL Languages or commands used in the SQL
queries:
1. Commit TCL Command
2. Rollback TCL Command

Let's discuss the above TCL commands one by one with syntax and
examples.

COMMIT Command

This command allows the database users to save the operations in the
database.

Syntax of Commit command:

COMMIT;
Rollback Command

This command allows the database users to restore the transactions to


that state which was last committed.

Syntax of Rollback command:

ROLLBACK;

You might also like