Nothing Special   »   [go: up one dir, main page]

Lab Assignment 1: Types of SQL Commands

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Lab Assignment 1

Types of SQL Commands

SUBMITTED TO: SIR ADEEL KHALID


SUBMITTED BY : RAHAM MEHMOOD NIAZI
ENROLLMENT No: 2016-MCS-038
COURSE TITLE : DBMS LAB
What is SQL?
SQL stands for Structured Query Language use for storing, manipulating and retrieving
relational database data.
SQL queries to retrieve data from database same as you can adding and manipulating database
data.

Types of SQL Commands:


These are the basic categories of commands used in SQL to perform various functions. These functions
include building database objects, manipulating objects, populating database tables with data, updating
existing data in tables, deleting data, performing database queries, controlling database access, and
overall database administration.

The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE,
DELETE and DROP. These commands can be classified into groups based on their nature:

The main categories are:


1. DDL (Data Definition Language)
2. DML (Data Manipulation Language)

3. DQL (Data Query Language)

4. DCL (Data Control Language)

5. Data administration commands

6. Transactional control commands

Data Definition Language (DDL) Commands:


Data Definition Language, DDL, is the part of SQL that allows a database user to create and restructure
database objects, such as the creation or the deletion of a table.
Some of the most fundamental DDL commands includes the following:

Command Description
CREATE Create new database/table
ALTER Modifies the structure of database/table.
DROP Deletes a database/table.
TRUNCATE Remove all table records including allocated table spaces.
RENAME Rename the database/table.
Data Manipulation Language (DML) :
Data Manipulation Language, DML, is the part of SQL used to manipulate data within objects of a
relational database.

Command Description
SELECT Retrieve data from the table.
INSERT Insert data into a table.
UPDATE Updates existing data with new data within a table.
DELETE Deletes the records rows from the table
MERGE MERGE (also called UPSERT) commands to INSERT new
records or UPDATE existing records depending on
condition matches or not.
LOCK TABLE LOCK TABLE commands to lock one or more tables in a
specified mode. Table access denied to a other users for
the duration of your table operation.

Data Query Language (DQL) :


Though comprised of only one command, Data Query Language (DQL) is the most concentrated focus of
SQL for modern relational database users. The base command is as follows:

Command Description
SELECT Retrieves certain records from one or more tables

Data Control Language (DCL):


Data control commands in SQL allow you to control access to data within the database. These DCL
commands are normally used to create objects related to user access and also control the distribution of
privileges among users. Some data control commands are as follows:

Command Description
GRANT Gives privileges to user for accessing database data.
REVOKE. Take back for given privileges
ANALYZE ANALYZE statement to collect statistics information
about index, cluster, table.
AUDIT To track the occurrence of a specific SQL statement or
all SQL statements during the user sessions.
COMMENT Write comment to the data table.
Data Administration Commands (DAC):
Data administration commands allow the user to perform audits and perform analyses on operations
within the database. They can also be used to help analyze system performance. Two general data
administration commands are as follows:

Command
START AUDIT
STOP AUDIT

Transactional Control Commands (TCC):


In addition to the previously introduced categories of commands, there are commands that allow the
user to manage database transactions. These are also use to apply the changes permanently save into
database.

Command Description
COMMIT Permanent work save into database.
ROLLBACK Restore database to original form since the last
COMMIT
SAVEPOINT Create SAVEPOINT for later use ROLLBACK the new
changes.
SET TRANSACTION SET TRANSACTION command set the transaction
properties such as read-write/read only access.

You might also like