You are on page 1of 2

Ms.

Access SQL My Sql Sql Server My Sql Gateway Navicate Lite Php My Admin Pertemuan I mysql> show databases; mysql> create database cb_perpustakaan; mysql> use db_perpustakaan; mysql> create table tb_buku (kode_buku varchar(10) not null, nama_buku varchar(40) not null, tanggal_beli date, primary key (kode_buku)); mysql> show tables; mysql> describe tb_buku; Pertemuan 2 Create Alter DDL Basis Data Rename Tabel Drop Database Tabel Database Table Database Table

Add Change Modify Drop Column

DML ALTER (Mengubah Struktur) mysql> alter table tb_buku ADD harga_buku int(8) not null; mysql> alter table tb_buku CHANGE harga_buku harga_bk int(6) not null; mysql> alter table tb_buku MODIFY harga_bk varchar(10) not null; mysql> alter table tb_buku DROP COLUMN harga_bk; mysql> RENAME table tb_buku TO t_buku; mysql> DROP table t_buku; mysql> DROP database db_perpustakaan
keterangan :

ADD CHANGE MODIFY DROP RENAME

: menambah : mengubah nama kolom : mengganti tipe : menhapus : mengubah nama

Pertemuan 3 db_pustaka tb_buku : kode_buku nama_buku tanggal_beli jumlah harga_buku DDL Insert (memasukkan data) Database Update (mengubah data) DML Delete (menghapus data) Retrival Data (memanggil data dalam jumlah sedikit) mysql> insert into tb_buku (kode_buku,nama_buku,tanggal_beli,jumlah,harga_buku) values (B001,LOGIKA ALGORITMA,2011-11-25,5,33000); mysql> select * from tb_buku; mysql> UPDATE tb_buku SET nama_buku=Pemograman Sistem Aktiva WHERE kode_buku=B006; mysql> DELETE FROM tb_buku WHERE kode_buku=B006; mysql> select kode_buku,nama_buku,jumlah,harga_buku from tb_buku; ASC (dari kecil ke besar) ORDER BY DESC (dari besar ke kecil) mysql> select kode_buku,nama_buku,jumlah,harga_buku from tb_buku ORDER BY nama_buku ASC; atau DESC; mysql> select kode_buku,nama_buku,jumlah, format (harga_buku,2.3) as harga from tb_buku ORDER BY nama_buku ASC;
fungsi matematika untuk menambah kolom

text(10) pk text(40) tanggal angka(8) angka(8)

mysql> select kode_buku,nama_buku,jumlah, format (harga_buku,2.3) as Harga Satuan, format ((jumlah * harga_buku),2.3) as Total from tb_buku ORDER BY nama_buku DESC;
COUNT SUM : menghitung record : menjumlah isi record

mysql> select count (kode_buku) as jumlah data from tb_buku; mysql> select sum (jumlah) as jumlah item buku from tb_buku;

You might also like