SQL Query Fundamentals Flashcards

1
Q

List the 4 Primary Types of SQL Queries?

A

SQL commands are mainly categorized into four categories as:

DDL – Data Definition Language
DQl – Data Query Language
DML – Data Manipulation Language
DCL – Data Control Language

Some consider TCL (Transaction Control Language ) a 5th type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data Definition Language (DDL) Commands

A

Data Definition Language (DDL):
DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema.

CREATE
ALTER
DROP
RENAME
TRUNCATE
COMMENT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Data Query Language (DQL) Commands

A

Data Query Language (DQL):
DQL statements are used for performing queries on the data within schema objects. The purpose of the DQL Command is to get some schema relation based on the query passed to it.

SELECT: It is used to retrieve data from the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Data Manipulation Language (DML) Commands

A

Data Manipulation Language (DML):
The SQL commands that deals with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements. It is the component of the SQL statement that controls access to data and to the database. Basically, DCL statements are grouped with DML statements.

INSERT
UPDATE
DELETE
MERGE
CALL
EXPLAIN PLAN
LOCK TABLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Data Control Language (DCL) Commands

A

Data Control Language (DCL):
DCL includes commands such as GRANT and REVOKE which mainly deal with the rights, permissions, and other controls of the database system.

GRANT
REVOKE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Transaction Control Language (TCL) Commands

A

Transaction Control Language (TCL):
Sometimes considered a 5th type of SQL commands.

Transactions group a set of tasks into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group successfully complete. If any of the tasks fail, the transaction fails. Therefore, a transaction has only two results: success or failure.

Incomplete steps result in the failure of the transaction. A database transaction, by definition, must be atomic, consistent, isolated and durable. These are popularly known as ACID properties.

COMMIT: Commits a Transaction.
ROLLBACK: Rollbacks a transaction in case of any error occurs.
SAVEPOINT:Sets a savepoint within a transaction.
SET TRANSACTION: Specify characteristics for the transaction.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly