4. Overview
● DDL or Data Definition Language actually consists of the SQL
commands that can be used to define the database schema
5. CREATE
used to create a new table in the database
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);
Example :
CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email
VARCHAR2(100), DOB DATE);
6. DROP
used to delete both the structure and record stored in the table
DROP TABLE table_name;
Example :
DROP TABLE EMPLOYEE;
7. ALTER
used to alter the structure of the database.
ALTER TABLE table_name ADD column_name COLUMN-definition;
Example :
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
8. TRUNCATE
used to delete all the rows from the table and free the space containing the
table
TRUNCATE TABLE table_name;
Example :
TRUNCATE TABLE EMPLOYEE;
10. INSERT
used to insert data into the row of a table
INSERT INTO TABLE_NAME
(col1, col2, col3,.... col N)
VALUES (value1, value2, value3, .... valueN);
Example :
INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo",
"DBMS");
11. UPDATE
This command is used to update or modify the value of a column in the table
UPDATE table_name SET [column_name1= value1,...column_nameN
= valueN] [WHERE CONDITION]
Example :
UPDATE students
SET User_Name = 'Sonoo'
WHERE Student_Id = '3'
12. DELETE
used to remove one or more row from a table.
DELETE FROM table_name [WHERE condition];
Example :
DELETE FROM javatpoint
WHERE Author="Sonoo";
14. Challenge I
Buat DDL dari Case Berikut
● Anda diminta untuk merancang sebuah database untuk sistem voting
pada suatu organisasi.
● Sistem voting ini memuat informasi tentang setiap pemilih, calon
yang bersaing, dan hasil voting.
● Database tersebut harus memuat informasi tentang setiap pemilih,
termasuk nama, alamat email, dan nomor telepon.
● Database juga harus memuat informasi tentang setiap calon, termasuk
nama, visi misi, dan foto.
15. Challenge II - Create DDL
● Anda diminta untuk merancang sebuah database untuk sebuah situs e-
commerce yang menjual berbagai produk, termasuk elektronik,
pakaian, dan barang-barang rumah tangga.
● Situs ini memuat informasi tentang produk, pelanggan, dan transaksi.
● Database juga harus memuat informasi tentang setiap kategori produk,
dan informasi pengiriman dan pembayaran.
16. Challenge II - Create DDL
Tabel Produk
● Nama Produk (varchar)
● Deskripsi Produk (text)
● Harga (float)
Tabel Kategori Produk
● Nama Kategori (varchar)
Tabel Pelanggan
Nama Pelanggan (varchar)
Alamat Pengiriman (varchar)
Nomor Telepon (varchar)
Alamat Email (varchar)
Tabel Transaksi
Waktu Pembelian (datetime)
Total Harga (float)
Status Pembayaran (boolean)
Tabel Detail Transaksi
Jumlah (integer)
17. Challenge III
● Buat sebuah ERD dan DDL dari sebuah aplikasi dengan tema sewa
lapangan futsal yang terdiri dari 3 lapangan