SQL Languages Flashcards

(30 cards)

1
Q

What are the 4 parts of SQL?

A
  • DDL
  • DML
  • DCL
  • TCL

These parts represent different functionalities within SQL.

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

What does SQL as a whole represent?

A

A complete toolkit for building, managing, securing, and safely modifying databases

SQL encompasses various operations for database management.

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

What is the purpose of DDL?

A

To build and change the structure of the database

DDL stands for Data Definition Language.

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

What does CREATE do?

A

Creates new objects like tables, views, indexes

CREATE is a fundamental command in DDL.

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

What does ALTER do?

A

Modifies an existing table’s structure (add/rename/change columns)

ALTER allows changes to the schema of a table.

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

What does DROP do?

A

Permanently deletes a table or object — no undo

DROP removes objects from the database entirely.

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

What does TRUNCATE do?

A

Deletes all rows but keeps the table structure

TRUNCATE is faster than DELETE as it does not log individual row deletions.

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

What’s the analogy for CREATE?

A

Constructing a new building

This analogy illustrates the creation of new database objects.

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

What’s the analogy for ALTER?

A

Renovating a room

This analogy represents modifying existing structures.

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

What’s the analogy for DROP?

A

Demolishing a building

This analogy signifies the complete removal of database objects.

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

What’s the analogy for TRUNCATE?

A

Clearing a building of furniture

This analogy emphasizes the removal of data while retaining the structure.

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

What does CREATE TABLE define?

A

Columns + data types (blueprint for data)

CREATE TABLE is essential for establishing a new table.

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

What is a VIEW?

A

A virtual window into data (a saved SELECT query)

Views simplify data access and can encapsulate complex queries.

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

What is CREATE INDEX used for?

A

Speeding up searching (like a book index)

Indexes improve query performance significantly.

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

What does a SCHEMA do?

A

Groups related tables together

Schemas help organize database objects.

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

What is a TRIGGER?

A

Automatic actions that run when something happens (e.g., auto email)

Triggers can enforce business rules automatically.

17
Q

What is the purpose of DML?

A

To work with the actual data inside tables

DML stands for Data Manipulation Language.

18
Q

What does SELECT do?

A

Retrieves data

SELECT is the primary command for data retrieval.

19
Q

What does INSERT do?

A

Adds new rows of data

INSERT is used to populate tables with data.

20
Q

What does UPDATE do?

A

Changes existing data

UPDATE modifies records in a table.

21
Q

What does DELETE do?

A

Removes rows

DELETE is used to remove specific records from a table.

22
Q

Why must you use WHERE with UPDATE/DELETE?

A

Without WHERE, you update/delete everything

Using WHERE ensures targeted modifications.

23
Q

What’s the analogy for DML?

A

Living inside the house after it’s built

This analogy illustrates working with data after its structure is established.

24
Q

What is the purpose of DCL?

A

Controls who can access or modify data — security

DCL stands for Data Control Language.

25
What does **GRANT** do?
Gives permissions (like giving someone a key card) ## Footnote GRANT allows users to perform specific actions on database objects.
26
What does **REVOKE** do?
Removes permissions (taking the key card back) ## Footnote REVOKE restricts access to database objects.
27
What is the purpose of **TCL**?
Manages changes safely — ensures data stays correct ## Footnote TCL stands for Transaction Control Language.
28
What does **COMMIT** do?
Saves all changes permanently ## Footnote COMMIT finalizes transactions in the database.
29
What does **ROLLBACK** do?
Undo all changes since the last BEGIN ## Footnote ROLLBACK reverts the database to a previous state.
30
What is **SAVEPOINT**?
A mini-checkpoint inside a transaction (restore point) ## Footnote SAVEPOINT allows partial rollbacks within transactions.