SlideShare a Scribd company logo
1 of 7
[Type text] Page 1
MATERI MINGGU 1 – Prak. BASISDATA
PENGANTAR MY SQL
LABORATORIUM 4 – BASISDATA
Melihat dafar database di komputer :
RUMUS :
SHOW DATABASES;
HASIL :
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| webauth |
+--------------------+
Membuat database baru :
RUMUS :
CREATE DATABASE(spasi)NAMA_DATABASE;
CONTOH :
mysql> create database lab4;
Query OK, 1 row affected (0.09 sec)
Memakai database yang telah kita buat
RUMUS :
USE(spasi)NAMA_DATABASE;
CONTOH :
mysql> use lab4;
Database changed
Membuat tabel baru :
RUMUS :
CREATE TABLE NAMA_TABEL
(
Nama_Kolom1(spasi)tipe_data(ukuran),
Nama_Kolom2(spasi)tipe_data(ukuran),
[Type text] Page 2
Nama_Kolom3(spasi)tipe_data(ukuran),
Nama_Kolom4(spasi)tipe_data(ukuran));
CONTOH :
mysql> create table t_mhs(nim varchar(10), nama_mhs varchar(50),
alamat varchar(50), no_telp varchar(12));
Query OK, 0 rows affected (0.16 sec)
Melihat hasil tabel yang kita buat :
RUMUS :
DESC(spasi)NAMA_TABEL;
CONTOH :
mysql> desc t_mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | varchar(10) | YES | | NULL | |
| nama_mhs | varchar(50) | YES | | NULL | |
| alamat | varchar(50) | YES | | NULL | |
| no_telp | varchar(12) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.08 sec)mysql> desc mahasiswa;
Input Data ke Dalam Tabel :
1. Menggunakan Rumus INSERT
2. Menggunakan Rumus LOAD DATA
1.Menginputkan data ke dalam tabel menggunakan perintah
INSERT
RUMUS :
Mysql >INSERT(spasi)INTO(spasi)NAMA_TABEL(spasi)VALUES
>(
>’DATA_KOLOM1’,
[Type text] Page 3
>’DATA_KOLOM2’,
>’DATA_KOLOM3’,
>’DATA_KOLOM4’
>);
CONTOH :
mysql> insert into t_mhs values( '111051005', 'Sholeh',
'Sleman','085785231478');
Query OK, 1 row affected (0.05 sec)
mysql> select *from t_mhs;
+-----------+----------+--------+--------------+
| nim | nama_mhs | alamat | no_telp |
+-----------+----------+--------+--------------+
| 111051005 | Sholeh | Sleman | 085785231478 |
+-----------+----------+--------+--------------+
5 rows in set (0.00 sec)
2.Menginputkan data ke dalam tabel menggunakan perintah
LOAD DATA
Persiapkan file yang berisi data yang akan diinputkan ke tabel
di database kita, sesuai dengan urutan yg kita buat di MYSQL.
Simpan dengan format .txt
CONTOH : (dibuat di MS.EXEL dan disimpan dengan nama data.txt
= format TEXT(MS-DOS) )
111051001 Uning Jogja 085786452315
111051002 Yuli Bantul 081354687923
111051003 Wanto Sleman 088869874563
111051004 Catur Bantul 081244455566
RUMUS :
LOAD(spasi)DATA(spasi)LOCAL(spasi)INFILE(spasi)
’LOKASI-FILE’(spasi)
INTO(spasi)
TABLE(spasi)
NAMA_TABEL
[Type text] Page 4
;
CONTOH :
mysql> load data local infile 'D://km1/data.txt' into table
t_mhs;
Query OK, 4 rows affected (0.03 sec)
Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
mysql> select*from t_mhs;
+-----------+----------+------------+---------------+
| nim | nama_mhs | alamat_mhs | no_telp |
+-----------+----------+------------+---------------+
|111051001 | Uning | Jogja | 085786452315
|111051002 | Yuli | Bantul | 081354687923
|111051003 | Wanto | Sleman | 088869874563
|111051004 | Catur | Bantul | 081244455566
+-----------+----------+------------+---------------+
4 rows in set (0.00 sec)
Menghapus database dan tabel
Buat dulu table baru
mysql> create table mat_kul(id_matkul varchar(10), nama_matkul
varchar(50), sks int(1), semester int(1), dosen varchar(10));
Query OK, 0 rows affected (0.02 sec)
mysql> desc mat_kul;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| id_matkul | varchar(10) | YES | | NULL | |
| nama_matkul | varchar(50) | YES | | NULL | |
| sks | int(1) | YES | | NULL | |
| semester | int(1) | YES | | NULL | |
| dosen | varchar(10) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
5 rows in set (0.03 sec)
Lihat tabel yang ada
[Type text] Page 5
mysql> show tables;
+----------------+
| Tables_in_lab4 |
+----------------+
| mat_kul |
| t_mhs |
+----------------+
2 rows in set (0.00 sec)
Hapus TABEL
DROP(spasi)TABLE(spasi)NAMA_TABEL
mysql> drop table mat_kul;
Query OK, 0 rows affected (0.02 sec)
mysql> show tables;
+----------------+
| Tables_in_lab4 |
+----------------+
| t_mhs |
+----------------+
1 row in set (0.00 sec)
Buat database baru
mysql> create database coba;
Query OK, 1 row affected (0.02 sec)
Lihat database yang ada
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| coba |
| lab4 |
| mysql |
| performance_schema |
| test |
[Type text] Page 6
+--------------------+
6 rows in set (0.00 sec)
HAPUS DATABASE
mysql> drop database coba;
Query OK, 0 rows affected (0.06 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| lab4 |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
[Type text] Page 7
LATIHAN 1
Kerjakan soal – soal di bawah ini dengan teliti..!!
1. Buatlah Database baru bernama SN1_LATIHAN1
2. Buatlah Tabel baru bernama T_Buku dengan kolom sbb :
+-----------+-------------+
| Field | Type |
+-----------+-------------+
| id_buku | varchar(8) |
| nama_buku | varchar(50) |
| pengarang | varchar(50) |
| penerbit | varchar(50) |
| harga | int(6) |
+-----------+-------------+
3. Isilah tabel T_Buku dengan data sbb :
+---------+--------------------+--------------+----------+-------+
| id_buku | nama_buku | pengarang | penerbit | harga |
+---------+--------------------+--------------+----------+-------+
| AA-001 | Pemrograman Pascal | Alfred Riedl | Erlangga | 50000 |
| AA-002 | SQL Server 5.0 | Jono Ricardo | MyBook | 85000 |
| BB-001 | Obat Anti Galau | Tim Galauers | Gramedia | 40000 |
| BB-002 | Humor Indonesia | Hendi Susan | Andi Ho | 30000 |
+---------+--------------------+--------------+----------+-------+
4. Buat laporan Latihan ini di Ms.Word atau Notepad dengan nama file
SN2_NIM_Latihan1
5. Simpan di Folder masing – masing

More Related Content

What's hot

Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Tesora
 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreDave Stokes
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in ElixirJesse Anderson
 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteRonald Bradford
 
The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 62 of 184
The Ring programming language version 1.5.3 book - Part 62 of 184The Ring programming language version 1.5.3 book - Part 62 of 184
The Ring programming language version 1.5.3 book - Part 62 of 184Mahmoud Samir Fayed
 
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erickokelloerick
 
PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개PgDay.Seoul
 
My SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTNMy SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTNRonald Bradford
 
groovy databases
groovy databasesgroovy databases
groovy databasesPaul King
 
Database administration commands
Database administration commands Database administration commands
Database administration commands Varsha Ajith
 
The Ring programming language version 1.7 book - Part 56 of 196
The Ring programming language version 1.7 book - Part 56 of 196The Ring programming language version 1.7 book - Part 56 of 196
The Ring programming language version 1.7 book - Part 56 of 196Mahmoud Samir Fayed
 

What's hot (20)

Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document Store
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in Elixir
 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That Bite
 
The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202
 
The Ring programming language version 1.5.3 book - Part 62 of 184
The Ring programming language version 1.5.3 book - Part 62 of 184The Ring programming language version 1.5.3 book - Part 62 of 184
The Ring programming language version 1.5.3 book - Part 62 of 184
 
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه چهارم کلاس پایتون برای هکرهای قانونی
 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erick
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개
 
My SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTNMy SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTN
 
Oracle ORA Errors
Oracle ORA ErrorsOracle ORA Errors
Oracle ORA Errors
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
The ABCs of OTP
The ABCs of OTPThe ABCs of OTP
The ABCs of OTP
 
groovy databases
groovy databasesgroovy databases
groovy databases
 
Codigos
CodigosCodigos
Codigos
 
Database administration commands
Database administration commands Database administration commands
Database administration commands
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
The Ring programming language version 1.7 book - Part 56 of 196
The Ring programming language version 1.7 book - Part 56 of 196The Ring programming language version 1.7 book - Part 56 of 196
The Ring programming language version 1.7 book - Part 56 of 196
 

Viewers also liked

SBTUG 28 July 2010 SQL Server 2008 R2
SBTUG 28 July 2010 SQL Server 2008 R2SBTUG 28 July 2010 SQL Server 2008 R2
SBTUG 28 July 2010 SQL Server 2008 R2Craig Bailey
 
Sql 2008 and project server 2010
Sql 2008 and project server 2010Sql 2008 and project server 2010
Sql 2008 and project server 2010Eduardo Castro
 
Modul Kelas Programming : Introduction to java
Modul Kelas Programming : Introduction to javaModul Kelas Programming : Introduction to java
Modul Kelas Programming : Introduction to javaFgroupIndonesia
 
My sql dari Pemula hingga Mahir (achmad solichin)
My sql dari Pemula hingga Mahir (achmad solichin)My sql dari Pemula hingga Mahir (achmad solichin)
My sql dari Pemula hingga Mahir (achmad solichin)FaRid Adwa
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetFaRid Adwa
 
Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1FgroupIndonesia
 
Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)FgroupIndonesia
 
Database Operation di VB.NET
Database Operation di VB.NETDatabase Operation di VB.NET
Database Operation di VB.NETFgroupIndonesia
 

Viewers also liked (8)

SBTUG 28 July 2010 SQL Server 2008 R2
SBTUG 28 July 2010 SQL Server 2008 R2SBTUG 28 July 2010 SQL Server 2008 R2
SBTUG 28 July 2010 SQL Server 2008 R2
 
Sql 2008 and project server 2010
Sql 2008 and project server 2010Sql 2008 and project server 2010
Sql 2008 and project server 2010
 
Modul Kelas Programming : Introduction to java
Modul Kelas Programming : Introduction to javaModul Kelas Programming : Introduction to java
Modul Kelas Programming : Introduction to java
 
My sql dari Pemula hingga Mahir (achmad solichin)
My sql dari Pemula hingga Mahir (achmad solichin)My sql dari Pemula hingga Mahir (achmad solichin)
My sql dari Pemula hingga Mahir (achmad solichin)
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 
Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1Modul Kelas Programming : Java swing 1
Modul Kelas Programming : Java swing 1
 
Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)Modul Kelas Programming : Java swing (session 2)
Modul Kelas Programming : Java swing (session 2)
 
Database Operation di VB.NET
Database Operation di VB.NETDatabase Operation di VB.NET
Database Operation di VB.NET
 

Similar to Materi my sql part 1

Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQLNaeem Junejo
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction databaseMudasir Syed
 
mysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptmysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptaptechaligarh
 
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-noteLeerpiny Makouach
 
15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboardsDenis Ristic
 
Introduction To Lamp P2
Introduction To Lamp P2Introduction To Lamp P2
Introduction To Lamp P2Amzad Hossain
 
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018teachersduniya.com
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesDave Stokes
 

Similar to Materi my sql part 1 (20)

My sql1
My sql1My sql1
My sql1
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQL
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
 
介绍 MySQL
介绍 MySQL介绍 MySQL
介绍 MySQL
 
mysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptmysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.ppt
 
My SQL
My SQLMy SQL
My SQL
 
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-note
 
MySql:Introduction
MySql:IntroductionMySql:Introduction
MySql:Introduction
 
MySQL Introduction
MySQL IntroductionMySQL Introduction
MySQL Introduction
 
15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards
 
MySQL Basics
MySQL BasicsMySQL Basics
MySQL Basics
 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
 
Instalar MySQL CentOS
Instalar MySQL CentOSInstalar MySQL CentOS
Instalar MySQL CentOS
 
Introduction To Lamp P2
Introduction To Lamp P2Introduction To Lamp P2
Introduction To Lamp P2
 
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
 

Recently uploaded

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 

Recently uploaded (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

Materi my sql part 1

  • 1. [Type text] Page 1 MATERI MINGGU 1 – Prak. BASISDATA PENGANTAR MY SQL LABORATORIUM 4 – BASISDATA Melihat dafar database di komputer : RUMUS : SHOW DATABASES; HASIL : +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | webauth | +--------------------+ Membuat database baru : RUMUS : CREATE DATABASE(spasi)NAMA_DATABASE; CONTOH : mysql> create database lab4; Query OK, 1 row affected (0.09 sec) Memakai database yang telah kita buat RUMUS : USE(spasi)NAMA_DATABASE; CONTOH : mysql> use lab4; Database changed Membuat tabel baru : RUMUS : CREATE TABLE NAMA_TABEL ( Nama_Kolom1(spasi)tipe_data(ukuran), Nama_Kolom2(spasi)tipe_data(ukuran),
  • 2. [Type text] Page 2 Nama_Kolom3(spasi)tipe_data(ukuran), Nama_Kolom4(spasi)tipe_data(ukuran)); CONTOH : mysql> create table t_mhs(nim varchar(10), nama_mhs varchar(50), alamat varchar(50), no_telp varchar(12)); Query OK, 0 rows affected (0.16 sec) Melihat hasil tabel yang kita buat : RUMUS : DESC(spasi)NAMA_TABEL; CONTOH : mysql> desc t_mhs; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | nim | varchar(10) | YES | | NULL | | | nama_mhs | varchar(50) | YES | | NULL | | | alamat | varchar(50) | YES | | NULL | | | no_telp | varchar(12) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 4 rows in set (0.08 sec)mysql> desc mahasiswa; Input Data ke Dalam Tabel : 1. Menggunakan Rumus INSERT 2. Menggunakan Rumus LOAD DATA 1.Menginputkan data ke dalam tabel menggunakan perintah INSERT RUMUS : Mysql >INSERT(spasi)INTO(spasi)NAMA_TABEL(spasi)VALUES >( >’DATA_KOLOM1’,
  • 3. [Type text] Page 3 >’DATA_KOLOM2’, >’DATA_KOLOM3’, >’DATA_KOLOM4’ >); CONTOH : mysql> insert into t_mhs values( '111051005', 'Sholeh', 'Sleman','085785231478'); Query OK, 1 row affected (0.05 sec) mysql> select *from t_mhs; +-----------+----------+--------+--------------+ | nim | nama_mhs | alamat | no_telp | +-----------+----------+--------+--------------+ | 111051005 | Sholeh | Sleman | 085785231478 | +-----------+----------+--------+--------------+ 5 rows in set (0.00 sec) 2.Menginputkan data ke dalam tabel menggunakan perintah LOAD DATA Persiapkan file yang berisi data yang akan diinputkan ke tabel di database kita, sesuai dengan urutan yg kita buat di MYSQL. Simpan dengan format .txt CONTOH : (dibuat di MS.EXEL dan disimpan dengan nama data.txt = format TEXT(MS-DOS) ) 111051001 Uning Jogja 085786452315 111051002 Yuli Bantul 081354687923 111051003 Wanto Sleman 088869874563 111051004 Catur Bantul 081244455566 RUMUS : LOAD(spasi)DATA(spasi)LOCAL(spasi)INFILE(spasi) ’LOKASI-FILE’(spasi) INTO(spasi) TABLE(spasi) NAMA_TABEL
  • 4. [Type text] Page 4 ; CONTOH : mysql> load data local infile 'D://km1/data.txt' into table t_mhs; Query OK, 4 rows affected (0.03 sec) Records: 4 Deleted: 0 Skipped: 0 Warnings: 0 mysql> select*from t_mhs; +-----------+----------+------------+---------------+ | nim | nama_mhs | alamat_mhs | no_telp | +-----------+----------+------------+---------------+ |111051001 | Uning | Jogja | 085786452315 |111051002 | Yuli | Bantul | 081354687923 |111051003 | Wanto | Sleman | 088869874563 |111051004 | Catur | Bantul | 081244455566 +-----------+----------+------------+---------------+ 4 rows in set (0.00 sec) Menghapus database dan tabel Buat dulu table baru mysql> create table mat_kul(id_matkul varchar(10), nama_matkul varchar(50), sks int(1), semester int(1), dosen varchar(10)); Query OK, 0 rows affected (0.02 sec) mysql> desc mat_kul; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | id_matkul | varchar(10) | YES | | NULL | | | nama_matkul | varchar(50) | YES | | NULL | | | sks | int(1) | YES | | NULL | | | semester | int(1) | YES | | NULL | | | dosen | varchar(10) | YES | | NULL | | +-------------+-------------+------+-----+---------+-------+ 5 rows in set (0.03 sec) Lihat tabel yang ada
  • 5. [Type text] Page 5 mysql> show tables; +----------------+ | Tables_in_lab4 | +----------------+ | mat_kul | | t_mhs | +----------------+ 2 rows in set (0.00 sec) Hapus TABEL DROP(spasi)TABLE(spasi)NAMA_TABEL mysql> drop table mat_kul; Query OK, 0 rows affected (0.02 sec) mysql> show tables; +----------------+ | Tables_in_lab4 | +----------------+ | t_mhs | +----------------+ 1 row in set (0.00 sec) Buat database baru mysql> create database coba; Query OK, 1 row affected (0.02 sec) Lihat database yang ada mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | coba | | lab4 | | mysql | | performance_schema | | test |
  • 6. [Type text] Page 6 +--------------------+ 6 rows in set (0.00 sec) HAPUS DATABASE mysql> drop database coba; Query OK, 0 rows affected (0.06 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | lab4 | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec)
  • 7. [Type text] Page 7 LATIHAN 1 Kerjakan soal – soal di bawah ini dengan teliti..!! 1. Buatlah Database baru bernama SN1_LATIHAN1 2. Buatlah Tabel baru bernama T_Buku dengan kolom sbb : +-----------+-------------+ | Field | Type | +-----------+-------------+ | id_buku | varchar(8) | | nama_buku | varchar(50) | | pengarang | varchar(50) | | penerbit | varchar(50) | | harga | int(6) | +-----------+-------------+ 3. Isilah tabel T_Buku dengan data sbb : +---------+--------------------+--------------+----------+-------+ | id_buku | nama_buku | pengarang | penerbit | harga | +---------+--------------------+--------------+----------+-------+ | AA-001 | Pemrograman Pascal | Alfred Riedl | Erlangga | 50000 | | AA-002 | SQL Server 5.0 | Jono Ricardo | MyBook | 85000 | | BB-001 | Obat Anti Galau | Tim Galauers | Gramedia | 40000 | | BB-002 | Humor Indonesia | Hendi Susan | Andi Ho | 30000 | +---------+--------------------+--------------+----------+-------+ 4. Buat laporan Latihan ini di Ms.Word atau Notepad dengan nama file SN2_NIM_Latihan1 5. Simpan di Folder masing – masing