DEV Community

Roby Cigar
Roby Cigar

Posted on

Database: DDL, DML, DCL, TCL

Gambar DDL, DML, DCL, TCL

Syntax database management berbasis SQL terbagi menjadi beberapa definisi yaitu: DDL, DML, DCL, TCL.
Berikut ini fungsi keempat definisi tersebut

1. DDL (Data Definition Language) :

Data Definition Language digunakan untuk membuat struktur database.
Contoh syntax dari DDL:

CREATE : to create objects in database
ALTER : alters the structure of database
DROP : delete objects from database
RENAME : rename an objects
Enter fullscreen mode Exit fullscreen mode

Berikut ini adalah DDL yang membuat table bernama department:

create table department
(dept_name  char(20),
  building   char(15),
  budget     numeric(12,2));
Enter fullscreen mode Exit fullscreen mode

2. DML (Data Manipulation Language) :

Data Manipulation Language digunakan untuk memanipulasi data yang ada pada database
Contoh perintah DML:

SELECT: retrieve data from the database
INSERT: insert data into a table
UPDATE: update existing data within a table
DELETE: deletes all records from a table, space for the records remain
Enter fullscreen mode Exit fullscreen mode

Contoh SQL query untuk menemukan nama semua instructors di dalam history department:

select instructor.name
 from instructor
 where instructor.dept_name = 'History';
Enter fullscreen mode Exit fullscreen mode

3. TCL (Transaction Control Language) :'

Transaction Control Language digunakan untuk mengatur transaksi pada database. TCL nantinya digunakan untuk memanage perubahan pada DML. Dengan kata lain, TCL digunakan bersamaan dengan DML.

Contoh perintah TCL:

COMMIT: Commit command is used to permanently save any transaction
            into the database.
ROLLBACK: This command restores the database to last committed state.
            It is also used with savepoint command to jump to a savepoint
            in a transaction.
SAVEPOINT: Savepoint command is used to temporarily save a transaction so
            that you can rollback to that point whenever necessary.
Enter fullscreen mode Exit fullscreen mode

DCL (Data Control Language) :

Data Control Language adalah syntax yang digunakan untuk memanajemen akses pada database.

Contoh perintah DCL :

GRANT: allow specified users to perform specified tasks.
REVOKE: cancel previously granted or denied permissions.
The operations for which privileges may be granted to or revoked from a user or role apply to both the Data definition language (DDL) and the Data manipulation language (DML), and may include CONNECT, SELECT, INSERT, UPDATE, DELETE, EXECUTE and USAGE. 
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)