Definition and Types of DML

Data Manipulation Language (DML) is a SQL query method that can be used after the database structure has been created using DDL (Data Definition Language). Simply put, DML is a set of query commands that function to manipulate data within a database.

The main commands in DML include INSERT to add data, UPDATE to change or replace data, and DELETE to remove data.

DML itself is divided into two main types:

  • Procedural DML: In this type, the commands used to manipulate data must be accompanied by clear instructions on how the data in the database file is accessed. Procedural DML is commonly used in high-level programming languages such as C and C++.
  • Non-Procedural DML: Unlike procedural DML, in non-procedural DML data can be manipulated directly without needing to include commands on how to access that data. Non-procedural DML is typically used in DBMS (Database Management System) such as Paradox, FoxPro, and SQL.

Uses of INSERT, UPDATE, and DELETE Commands in SQL

Below is a more detailed explanation of the three basic DML commands along with examples of their usage:

1. INSERT Command

INSERT is a command used to add or insert new rows of data into a table in the database.

Syntax:

sql

INSERT INTO table_name (column_data) VALUES (data_values);

Example:

sql

INSERT INTO Jurusan (KodeJur, NamaJur) VALUES ('12', 'Teknik Informatika');

Explanation: The command above is used to add new data to the “Jurusan” table. The “KodeJur” column will be filled with the value 12, while the “NamaJur” column will be filled with Teknik Informatika.

2. UPDATE Command

UPDATE is a command used to change, update, or replace existing data in the database.

Syntax:

sql

UPDATE table_name SET column_name = new_column_value WHERE condition;

Example:

sql

UPDATE Mahasiswa SET Nama='Wilan' WHERE No='1123';

Explanation: This command means we are modifying data in the “Mahasiswa” table, specifically replacing the content of the “Nama” column with Wilan, only for the row that has a “No” value equal to 1123.
Important Note: If the WHERE condition is not included, the system will change all data in that column for every row.

3. DELETE Command

DELETE is a command used to delete rows of data from the database.

Syntax:

sql

DELETE FROM table_name WHERE condition;

Example:

sql

DELETE FROM Mahasiswa WHERE No='1123';

Explanation: This command is useful for deleting data from the “Mahasiswa” table that has a “No” (or student ID) record of 1123.
Important Note: Deleting data using DELETE is highly dependent on the WHERE condition used. You should always double-check whether the DELETE command is defined with the correct condition so that no important data is accidentally deleted.

Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *