widayat s prasetiyo, s

22
Widayat S Prasetiyo, S.Kom

Upload: others

Post on 05-Oct-2021

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Widayat S Prasetiyo, S

Widayat S Prasetiyo, S.Kom

Page 2: Widayat S Prasetiyo, S

DAFTAR ISI1. STANDAR KOMPETENSI

2. LATAR BELAKANG

Page 3: Widayat S Prasetiyo, S

STANDAR KOMPETENSI1. Pemograman Data Deskripsi (SQL) tingkat

dasar

2. Mengoperasikan Bahasa Pemograman Data Deskripsi (SQL) tingkat lanjut

3. Mengoperasikan Program Basis Data

Page 4: Widayat S Prasetiyo, S

PERANGKAT LUNAK BERBASIS SQL

Perangkat lunak yang akan kita gunakan adalan MySQL Server.

Kebutuhan Sistem Operasi

MYSQL SERVER dapat digunakan dalam berbagai jenis Sistem Operasi baik ituWindows atau LINUX.

Disarankan menggunakan Sistem Operasi versi Server.

Page 5: Widayat S Prasetiyo, S

PAKET INSTALASI MySQL Terdapat 3 (tiga) paket untuk sistem operasi Windows

The Essentials Package

mysql-essential-5.x.x-win32.msi and contains the minimum set of files needed to install MySQL on Windows

The Complete Package

mysql-5.x.x-win32.zip and contains all files needed for a complete Windows installation

The Noinstall Archive

mysql-noinstall-5.x.x-win32.zip and contains all the files found in the Complete install package

Page 6: Widayat S Prasetiyo, S

STORAGE ENGINE

MYISAM The default MySQL storage engine and the one that is used the most in Web, data warehousing, and other application environments

INNODB A transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.

MEMORY Stores all data in RAM for extremely fast access in environments that require quick lookups of reference and other like data.

Page 7: Widayat S Prasetiyo, S

FITUR STORAGE ENGINEFeature MyISAM Memory InnoDB

Storage limits 256TB RAM 64TB

Transactions No No Yes

Foreign key support

No No Yes

Query cache support

Yes Yes Yes

Page 8: Widayat S Prasetiyo, S

DATA TYPE

1. NUMERIC TYPE

2. DATE AND TIME TYPE

3. STRING / CHARACTER TYPE

Setiap tipe data berdasarkan fitur darikategori database (storage engine)

Page 9: Widayat S Prasetiyo, S

NUMERIC TYPE TINYINT[(M)] [UNSIGNED]

A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

SMALLINT[(M)] [UNSIGNED]

A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.

MEDIUMINT[(M)] [UNSIGNED]

A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.

Page 10: Widayat S Prasetiyo, S

NUMERIC TYPE INT[(M)] [UNSIGNED]

A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

BIGINT[(M)] [UNSIGNED]

A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

FLOAT[(M,D)] [UNSIGNED]

A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.

DECIMAL[(M[,D])] [UNSIGNED]

A packed “exact” fixed-point number. M is the total number of digits (the precision) and D is the number of digits after the decimal point (the scale).

Page 11: Widayat S Prasetiyo, S

DATE AND TIME TYPE DATE

A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATEvalues in 'YYYY-MM-DD' format, but permits assignment of values to DATEcolumns using either strings or numbers.

DATETIME

A date and time combination. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

MySQL displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format, but permits assignment of values to DATETIME columns using either strings or numbers.

TIMESTAMP

A timestamp. The range is '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

TIMESTAMP values are stored as the number of seconds since the epoch ('1970-01-01 00:00:00' UTC).

Page 12: Widayat S Prasetiyo, S

DATE AND TIME TYPE TIME

A time. The range is '-838:59:59' to '838:59:59'. MySQL displays TIME values in 'HH:MM:SS' format, but permits assignment of values to TIME columns using either strings or numbers.

YEAR[(2|4)]

A year in two-digit or four-digit format. The default is four-digit format. In four-digit format, the allowable values are 1901 to 2155, and 0000.

In two-digit format, the allowable values are 70 to 69, representing years from 1970 to 2069.

Page 13: Widayat S Prasetiyo, S

STRING TYPE CHAR(M)

A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.

VARCHAR(M)

A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535.

TEXT[(M)]

A TEXT column with a maximum length of 65,535 (216 – 1) characters. The effective maximum length is less if the value contains multi-byte characters.

Page 14: Widayat S Prasetiyo, S

STRING TYPE TINYTEXT

A TEXT column with a maximum length of 255 (28 – 1) characters.

ENUM('value1','value2',...)An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value.

BLOB[(M)]

A BLOB column with a maximum length of 65,535 (216 – 1) bytes.

Page 15: Widayat S Prasetiyo, S

USER TYPE User/Account MySQL tersimpan dalam tabel dalam database

mysql

Setiap user diberikan hak akses terhadap database untukdapat menjalankan beberapa perintah DDL dan DML .

User yang memiliki hak penuh (GRANT ALL) adalah root (seperti user admin dalam sistem operasi LINUX)

Page 16: Widayat S Prasetiyo, S

LATIHAN SQLSQL : CREATE DATABASE LAT_01

CREATE DATABASE `lat_01`;

USE `lat_01`;

Untuk memulai membuat table , aktifkan database latihan inidengan menggunakan perintah.

Page 17: Widayat S Prasetiyo, S

LATIHAN SQLSQL : CREATE TABLE SISWA

CREATE TABLE `lat_01`.`siswa`(

`NoInduk` VARCHAR(10) NOT NULL, `NamaSiswa` VARCHAR(30), `Alamat` VARCHAR(30), `Kota` VARCHAR(20), `Telepon` VARCHAR(15), `IdProgram` INT(10),PRIMARY KEY (`NoInduk`)

)ENGINE = MYISAM;

Page 18: Widayat S Prasetiyo, S

MYSQL versus Ms.ACCESS

MYSQL MICROSOFT ACCESS

VARCHAR, CHAR, TINYTEXT,

MEDIUMTEXT, LONGTEXT, TEXTTEXT

INT,SMALLINT, DECIMAL, BIGINT,

DOUBLE, FLOAT, NUMERICNUMERIC

DATE, YEAR, TIME,

DATETIME, TIMESTAMPDATE / TIME

DECIMAL, DOUBLE,

FLOAT, REALCURRENCY

BIT, ENUM, SET,

BOOL, BOOLEANYES / NO

BLOB, TINYBLOB,

MEDIUMBLOB, LONGBLOBOLE OBJECT

Perbandingan Tipe Data Database

Page 19: Widayat S Prasetiyo, S

STATEMENT SQLSQL : INSERT DATA

INSERT INTO table-name (column-1 [ , column-n]... ){ query-specification | VALUES (insert-value-1 [ , insert-

value-n]... )}

Example :

INSERT INTO siswa (nama_siswa,tgl_lahir)VALUES (‘budi’ ,’1994-08-22’) ;

Page 20: Widayat S Prasetiyo, S

STATEMENT SQLSQL : UPDATE DATA

UPDATE table-nameSET column-1 = { expression | NULL}

[ , column-n = { expression | NULL}]... [ WHERE search-condition]

Example :

UPDATE guruSET jabatan = ‘KEPALA SEKOLAH’ ,

alamat = NULLWHERE Kode_guru = ‘’GURU_1’

Page 21: Widayat S Prasetiyo, S

STATEMENT SQLSQL : DELETE DATA

DELETE FROM table-name[ WHERE search-condition]

Example :

DELETE FROM Nilai WHERE Kode_Siswa = 2345 AND No_Ujian = ‘UJI_0909’

Page 22: Widayat S Prasetiyo, S

Kritik & saran kirimkan ke :