DML Presentation
DML Presentation
DML stands for Data Manipulation Language. It is a part of SQL that allows
us to interact with and modify the data inside a database. DML helps us add,
update, retrieve, or remove files from it.
● Retrieved data
● Insert new records
● Update existing records
● Delete unwanted records
The primary DML commands include:
DML is essential for interacting with the data stored in a database, enabling
users to modify existing records and maintain data consistency. Without DML, a
database would be just a static collection of information. DML makes it dynamic,
allowing users to manage data efficiently in real-time.
For example:
Since DML modifies data, it has a direct impact on how databases perform and
function. Key effects:
● DML allows users to update records, ensuring information stays relevant and
accurate.
2. Transaction Control
● Operations like COMMIT (to save changes) and ROLLBACK (to undo changes)
help maintain data integrity.
3. Performance Considerations
● Too many DML operations can slow down a database, especially with large
datasets. Optimization is needed
4. Concurrency Control
● When multiple users modify data at the same time, databases ensure that no
conflicts occur.
● DML works alongside constraints (like PRIMARY KEY and FOREIGN KEY) to
maintain accuracy and prevent unauthorized changes.
Inserting Data into Tables
table_name:
● The name of the table where you want to update the data.
column1 = value1, column2 = value2, …:
● Specifies the columns you want to modify and their new values.
WHERE condition:
● Specifies the conditions that determine which rows to update.
Using WHERE to Target Specific Records
The WHERE clause ensures that only specific records are updated.
Updating Multiple Rows at Once:
You can update multiple rows with a single statement by using conditions in the
WHERE clause.
Importance of Careful Updates to Avoid
Accidental Changes:
The importance of careful updates to avoid accidental changes can be
understood through proper UPDATE syntax
Deleting Data from Tables
Concept of Transactions:
● A transaction is a bunch of database commands (like adding,
changing, or removing data) that are treated as one single action.
Either all the commands succeed, or none of them do. This is
important because it keeps the data consistent and reliable.
Ensuring Data Integrity:
Think about transferring money between bank accounts. You wouldn't want the
money to be taken from one account but not added to the other. Transactions prevent
this. If any part of the transaction fails, the entire thing is undone, keeping everything
consistent.
In short, transactions are like a safety net for your database changes. They make
sure everything is consistent and reliable. SAVEPOINT gives you even more control
by letting you undo only parts of a transaction.