0% found this document useful (0 votes)
9 views3 pages

SQL DDL Part2

The document outlines a practical exercise involving Data Definition Language (DDL) and Data Manipulation Language (DML) using MySQL. It includes instructions for creating a banking database with specific tables and fields, as well as SQL commands for modifying and populating these tables. Additionally, it provides guidance on logging MySQL commands and submitting the results as a text file.

Uploaded by

Ruth Manurung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

SQL DDL Part2

The document outlines a practical exercise involving Data Definition Language (DDL) and Data Manipulation Language (DML) using MySQL. It includes instructions for creating a banking database with specific tables and fields, as well as SQL commands for modifying and populating these tables. Additionally, it provides guidance on logging MySQL commands and submitting the results as a text file.

Uploaded by

Ruth Manurung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PRAKTIKUM DDL Part 2

Pokok Bahasan Data Definition Language (DDL)


Data Manipulation Language (DML)
TIK 1. Memahami konsep SQL
2. Membuat query dengan baik dan benar
3. Memahami cara kerja dan fitur-fitur yang dimiliki DBMS
MySQL serta mampu mengimplementasikan aplikasi
database dalam DBMS MySQL
Setoran File teks hasil log MySQL

Petunjuk:
Gunakan option --tee=<nama-file>.txt pada saat menjalankan mysql agar semua
perintah yang dijalankan tersimpan dalam sebuah file teks. File text tersebut yang harus
Anda kumpulkan sebagai hasil praktikum.

1. Buatlah sebuah database bernama banking.


2. Di dalam database tersebut, buatlah tabel-tabel berikut :
a. Nama tabel : account
Field Type Constraint
number char(3) not null, primary key
cust_id integer not null,
foreign key references customer(id)
balance numeric(9,2) not null
type varchar(10) not null

b. Nama tabel : deposit


Field Type Constraint
account_number char(3) not null,
foreign key references
account(number)
transaction_id char(5) not null, primary key
date date not null
dep_amount numeric(9,2) not null

c. Nama tabel : checks


Field Type Constraint
account_number char(3) not null, primary key,
foreign key references
account(number)
check_number char(7) not null, primary key
date date not null
amount numeric(9,2) not null

1
d. Nama tabel : atmwithdrawal
Field Type Constraint
transaction_id integer not null, primary key
account_number char(3) not null
foreign key references
account(number)
amount numeric(9,2) not null
withdraw_date date not null

e. Nama tabel : customer


Field Type Constraint
id integer not null, primary key
name varchar(20) not null
phone varchar(15) not null
address varchar(20) not null

3. Buatlah kalimat SQL untuk:


a. Menambahkan sebuah field baru pada tabel atmwithdrawal bernama cust_id
dengan type char(3) dan merupakan foreign key ke tabel customer(id)
Jawaban : ALTER TABLE atmwithdrawal MODIFY cust_id INT NOT NULL;
b. Mengganti nama field dep_amount menjadi amount dengan type numeric(9,2)
Jawaban : ALTER TABLE deposit CHANGE dep_amount amount NUMERIC(9,2)
NOT NULL;

4. Isilah tabel-tabel tersebut dengan data berikut:


a. Nama tabel : customer
id name phone address
1 J. Smith 335-6789 Stamford
3 M. Jones 552-9876 Harrison

b. Nama tabel : account


number cust_id balance type
101 1 1000 checking
104 3 1000 checking

c. Nama tabel : checks


account_number check_number date amount
104 104-237 2008-04-09 1000
101 101-889 2008-04-13 500

2
d. Nama tabel : deposit
account_number transaction_id date amount
101 D-001 2008-04-01 500
101 D-004 2008-04-05 2500

e. Nama tabel : atmwithdrawal


transaction_id cust_id account_number amount withdraw_date
3 1 101 40 2008-04-12
4 3 104 200 2008-04-13

5. Buatlah kalimat SQL untuk:


a. Mengubah field address dari customer dengan name M. Jones menjadi Pittsfield
Jawaban : UPDATE customer SET address = 'Pittsfield' WHERE name = 'M. Jones';
b. Menambah balance dari semua account bertype checking dengan 15%
Jawaban : UPDATE account SET balance = balance * 1.15 WHERE type = 'Checking';
c. Menghapus data deposit tanggal 2008-04-09
Jawaban : DELETE FROM DEPOSIT WHERE date = '2008-04-09';

6. Upload file P02YYXXX.txt ke learning-if.polibatam.ac.id pada tempat yang


disediakan

You might also like