Câu hỏi phỏng vấn MySQL
Câu hỏi

What is the difference between Data Definition Language (DDL) and Data Manipulation Language
(DML)?

Câu trả lời

Data Definition Language (DDL) and Data Manipulation Language (DML) are both subsets of SQL (Structured Query Language), which is used to manage and interact with databases. However, they serve different purposes and operate on different aspects of the database.

Data Definition Language (DDL)

DDL is used to define and modify the structure of database schemas. This includes creating, altering, and deleting database objects such as tables, indexes, and views. DDL commands do not manipulate data within the tables themselves but rather define how the database should be structured. Some of the common DDL commands include:

  • CREATE: Used to create new database objects, like tables or indexes.
  • ALTER: Used to modify existing database objects.
  • DROP: Used to delete database objects.
  • TRUNCATE: Used to remove all records from a table, including all spaces allocated for the records.
  • RENAME: Used to rename database objects.

DDL commands are auto-committed, meaning that once they are executed, the changes are saved permanently to the database, and they cannot be rolled back[2][3][4][5][6][7].

Data Manipulation Language (DML)

DML, on the other hand, is used for managing data within the database. This includes inserting, updating, deleting, and retrieving data from database tables. DML commands directly affect the data itself and not the structure of the database. Common DML commands include:

  • SELECT: Used to retrieve data from the database.
  • INSERT: Used to add new data to tables.
  • UPDATE: Used to modify existing data in the...
junior

junior

Gợi ý câu hỏi phỏng vấn

junior

What is self referencing foreign key? Give an example.

senior

What does OPTIMIZE TABLE command do in MySQL?

expert

Why you should never use GUIDs as part of clustered index?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào