SlideShare a Scribd company logo
Instalasi & Menggunakan Mysql
Fakhrian Fadlia Adiwijaya, S.Kom
Installasi XAMPP
1. Periksa pengaturan User Account Control
Installasi XAMPP
2. Pilih Komponen yang akan diistall 3. Pilih folder instalasi , dimana xampp akan disimpan
Installasi XAMPP
4. Pilihan CMS (Content Management System) 5. Mulai installasi XAMPP
Installasi XAMPP
6. Proses Installasi 7. Intallasi XAMMP selesai
Installasi XAMPP
8. Tampilan XAMPP Control Panel 9. Aktifkan Apache & Mysql
Mulai Menggunakan Mysql
1. Buka command prompt
Mulai Menggunakan Mysql
2. Masuk ke directori mysql
CD C:/xampp/mysql/bin
CD C:/wamp/bin/mysql/mysql5.1.30/bin
Mulai Menggunakan Mysql
3. Login Mysql (Default user : root tanpa password)
Mysql –u root –p
Pengelolaan Database
1. Membuat Database
3. Memodifikasi Database
Create Database [if not exists] <nama database>
[[DEFAULT] Character Set <nama character set]
[[DEFAULT] Collate <nama collation>]
Alter Database <nama database>
[[DEFAULT] Character Set <nama character set]
[[DEFAULT] Collate <nama collation>]
4. Menghapus Database
Drop Database [if exists] <nama database>
Create Database TokoBuku;
Alter Database TokoBuku
Character set latin1;
Drop Database IF EXISTS TokoBuku;
2. Menggunakan Database
Use <nama database> Use TokoBuku;
Pengelolaan Table
Create Table <nama tabel> (<Elemen Tabel> ::= <definisi kolom)
1. Membuat Tabel
2. Menghapus Tabel
Drop Table [if exists] <nama tabel>
3. Melihat Pembuatan Tabel
Show Create Table <nama tabel>
Pengelolaan Table
Memodifikasi Tabel
ALTER TABLE <nama tabel> MODIFY <nama kolom> <tipe data>)
1. Merubah Tipe Data Kolom
2. Merubah Nama Kolom
ALTER TABLE <nama tabel> CHANGE <nama kolom lama> <nama kolom baru> <tipe data>
RENAME TABLE <nama tabel lama> TO <nama tabel baru>
3. Merubah Nama Tabel
4. Menambah Kolom / Aksi Tabel
ALTER TABLE <nama tabel > ADD <nama kolom> <tipe data>
ALTER TABLE <nama tabel> DROP <nama kolom>
5. Menghapus Kolom Tabel
Contoh Alter Table
CREATE TABLE pembelian (
IDPembelian SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
IDModel SMALLINT UNSIGNED NOT NULL,
DeskripsiModel VARCHAR(40)
);
ALTER TABLE pembelian ADD UNIQUE KEY (IDModel);
CREATE TABLE pembelian (
IDPembelian SMALLINT UNSIGNED NOT NULL,
IDModel SMALLINT UNSIGNED,
DeskripsiModel VARCHAR(40),
PRIMARY KEY (IDPembelian),
UNIQUE KEY (IDModel)
);
Contoh Alter Table
CREATE TABLE pembelian (
IDPembelian SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
IDModel SMALLINT UNSIGNED NOT NULL,
DeskripsiModel VARCHAR(40)
);
CREATE TABLE pembelian (
IDPembelian SMALLINT UNSIGNED NOT NULL,
IDModel SMALLINT UNSIGNED NOT NULL,
DeskripsiModel VARCHAR(40),
PRIMARY KEY (IDPembelian, IDModel)
);
ALTER TABLE pembelian ADD PRIMARY KEY (IDModel);
ALTER TABLE pembelian DROP PRIMARY KEY, ADD PRIMARY KEY (IDPembelian,IDModel);
Contoh Alter Table
Contoh Alter Table
ALTER TABLE katalog CHANGE IDProduk IDProduk SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
CREATE TABLE katalog(
IDProduk SMALLINT UNSIGNED NOT NULL,
Nama VARCHAR(40) NOT NULL,
PRIMARY KEY (IDProduk)
);
CREATE TABLE katalog(
IDProduk SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
Nama VARCHAR(40) NOT NULL,
PRIMARY KEY (IDProduk)
);
ALTER TABLE katalog MODIFY IDProduk SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
Contoh Alter Table
CREATE TABLE model(
IDModel SMALLINT UNSIGNED NOT NULL,
Nama_Model VARCHAR(15) NOT NULL,
Jenis_Model VARCHAR(15) NOT NULL,
PRIMARY KEY (IDModel)
);
CREATE TABLE pembelian (
IDPembelian SMALLINT UNSIGNED NOT NULL,
IDModel SMALLINT UNSIGNED NOT NULL,
DeskripsiModel VARCHAR(40),
PRIMARY KEY (IDPembelian)
);
CREATE TABLE pembelian (
IDPembelian SMALLINT UNSIGNED NOT NULL,
IDModel SMALLINT UNSIGNED NOT NULL,
DeskripsiModel VARCHAR(40),
PRIMARY KEY (IDPembelian),
FOREIGN KEY (IDModel) REFERENCES model(IDModel)
ON DELETE RESTRICT / NO ACTION / CASCADE ON UPDATE RESTRICT / NO ACTION / CASCADE
);
TERIMA KASIH

More Related Content

Similar to 00. instalasi dan penggunaan mysql

Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
oly07104
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to databaseKazi Uddin Oly
 
MYSql manage db
MYSql manage dbMYSql manage db
MYSql manage db
Ahmed Farag
 
Unit_III_SQL-MySQL-Commands-Basic.pptx usefull
Unit_III_SQL-MySQL-Commands-Basic.pptx  usefullUnit_III_SQL-MySQL-Commands-Basic.pptx  usefull
Unit_III_SQL-MySQL-Commands-Basic.pptx usefull
ANTOARA2211003040050
 
SQL-MySQL-Commands-Basic.pptx
SQL-MySQL-Commands-Basic.pptxSQL-MySQL-Commands-Basic.pptx
SQL-MySQL-Commands-Basic.pptx
Karthikeyan Muthukrishnan
 
Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
StephenEfange3
 
MYSQL
MYSQLMYSQL
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-noteLeerpiny Makouach
 
Lec 07 SQL - 1.pptx
Lec 07 SQL - 1.pptxLec 07 SQL - 1.pptx
Lec 07 SQL - 1.pptx
HasankaNayanjith
 
Unidad 4 actividad 1
Unidad 4 actividad 1Unidad 4 actividad 1
Unidad 4 actividad 1KARY
 
My sql presentation
My sql presentationMy sql presentation
My sql presentationNikhil Jain
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
Manish Bothra
 
mysql 1st. act.
mysql 1st. act.mysql 1st. act.
mysql 1st. act.von lozano
 

Similar to 00. instalasi dan penggunaan mysql (16)

Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
MYSql manage db
MYSql manage dbMYSql manage db
MYSql manage db
 
Unit_III_SQL-MySQL-Commands-Basic.pptx usefull
Unit_III_SQL-MySQL-Commands-Basic.pptx  usefullUnit_III_SQL-MySQL-Commands-Basic.pptx  usefull
Unit_III_SQL-MySQL-Commands-Basic.pptx usefull
 
Les20
Les20Les20
Les20
 
SQL-MySQL-Commands-Basic.pptx
SQL-MySQL-Commands-Basic.pptxSQL-MySQL-Commands-Basic.pptx
SQL-MySQL-Commands-Basic.pptx
 
Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
 
MYSQL
MYSQLMYSQL
MYSQL
 
Plsql
PlsqlPlsql
Plsql
 
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-note
 
Lec 07 SQL - 1.pptx
Lec 07 SQL - 1.pptxLec 07 SQL - 1.pptx
Lec 07 SQL - 1.pptx
 
Unidad 4 actividad 1
Unidad 4 actividad 1Unidad 4 actividad 1
Unidad 4 actividad 1
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
mysql 1st. act.
mysql 1st. act.mysql 1st. act.
mysql 1st. act.
 
Introduction to mysql part 3
Introduction to mysql part 3Introduction to mysql part 3
Introduction to mysql part 3
 

More from Fakhrian Fadlia Adiwijaya

Algoritma & Pemograman - 02. Variabel dan Tipe Data
Algoritma & Pemograman - 02. Variabel dan Tipe DataAlgoritma & Pemograman - 02. Variabel dan Tipe Data
Algoritma & Pemograman - 02. Variabel dan Tipe Data
Fakhrian Fadlia Adiwijaya
 
Basis Data I - 01. Pendahuluan Basis Data
Basis Data I - 01. Pendahuluan Basis DataBasis Data I - 01. Pendahuluan Basis Data
Basis Data I - 01. Pendahuluan Basis Data
Fakhrian Fadlia Adiwijaya
 
Algoritma & Pemograman - 01.Pendahuluan
Algoritma & Pemograman - 01.PendahuluanAlgoritma & Pemograman - 01.Pendahuluan
Algoritma & Pemograman - 01.Pendahuluan
Fakhrian Fadlia Adiwijaya
 
08. mengakses multiple tabel
08. mengakses multiple tabel08. mengakses multiple tabel
08. mengakses multiple tabel
Fakhrian Fadlia Adiwijaya
 
07. menggunakan fungsi
07. menggunakan fungsi07. menggunakan fungsi
07. menggunakan fungsi
Fakhrian Fadlia Adiwijaya
 
05. manipulasi data update,delete &amp; seleksi
05. manipulasi data   update,delete &amp; seleksi05. manipulasi data   update,delete &amp; seleksi
05. manipulasi data update,delete &amp; seleksi
Fakhrian Fadlia Adiwijaya
 
04. manipulasi data perintah insert
04. manipulasi data   perintah insert04. manipulasi data   perintah insert
04. manipulasi data perintah insert
Fakhrian Fadlia Adiwijaya
 
03. index
03. index03. index
02. relational model dan query languages
02. relational model dan query languages02. relational model dan query languages
02. relational model dan query languages
Fakhrian Fadlia Adiwijaya
 
02. primary key, foreign key
02. primary key, foreign key02. primary key, foreign key
02. primary key, foreign key
Fakhrian Fadlia Adiwijaya
 
01. pengelolaan database, tabel upload
01. pengelolaan database, tabel upload01. pengelolaan database, tabel upload
01. pengelolaan database, tabel upload
Fakhrian Fadlia Adiwijaya
 

More from Fakhrian Fadlia Adiwijaya (11)

Algoritma & Pemograman - 02. Variabel dan Tipe Data
Algoritma & Pemograman - 02. Variabel dan Tipe DataAlgoritma & Pemograman - 02. Variabel dan Tipe Data
Algoritma & Pemograman - 02. Variabel dan Tipe Data
 
Basis Data I - 01. Pendahuluan Basis Data
Basis Data I - 01. Pendahuluan Basis DataBasis Data I - 01. Pendahuluan Basis Data
Basis Data I - 01. Pendahuluan Basis Data
 
Algoritma & Pemograman - 01.Pendahuluan
Algoritma & Pemograman - 01.PendahuluanAlgoritma & Pemograman - 01.Pendahuluan
Algoritma & Pemograman - 01.Pendahuluan
 
08. mengakses multiple tabel
08. mengakses multiple tabel08. mengakses multiple tabel
08. mengakses multiple tabel
 
07. menggunakan fungsi
07. menggunakan fungsi07. menggunakan fungsi
07. menggunakan fungsi
 
05. manipulasi data update,delete &amp; seleksi
05. manipulasi data   update,delete &amp; seleksi05. manipulasi data   update,delete &amp; seleksi
05. manipulasi data update,delete &amp; seleksi
 
04. manipulasi data perintah insert
04. manipulasi data   perintah insert04. manipulasi data   perintah insert
04. manipulasi data perintah insert
 
03. index
03. index03. index
03. index
 
02. relational model dan query languages
02. relational model dan query languages02. relational model dan query languages
02. relational model dan query languages
 
02. primary key, foreign key
02. primary key, foreign key02. primary key, foreign key
02. primary key, foreign key
 
01. pengelolaan database, tabel upload
01. pengelolaan database, tabel upload01. pengelolaan database, tabel upload
01. pengelolaan database, tabel upload
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 

00. instalasi dan penggunaan mysql

  • 1. Instalasi & Menggunakan Mysql Fakhrian Fadlia Adiwijaya, S.Kom
  • 2. Installasi XAMPP 1. Periksa pengaturan User Account Control
  • 3. Installasi XAMPP 2. Pilih Komponen yang akan diistall 3. Pilih folder instalasi , dimana xampp akan disimpan
  • 4. Installasi XAMPP 4. Pilihan CMS (Content Management System) 5. Mulai installasi XAMPP
  • 5. Installasi XAMPP 6. Proses Installasi 7. Intallasi XAMMP selesai
  • 6. Installasi XAMPP 8. Tampilan XAMPP Control Panel 9. Aktifkan Apache & Mysql
  • 7. Mulai Menggunakan Mysql 1. Buka command prompt
  • 8. Mulai Menggunakan Mysql 2. Masuk ke directori mysql CD C:/xampp/mysql/bin CD C:/wamp/bin/mysql/mysql5.1.30/bin
  • 9. Mulai Menggunakan Mysql 3. Login Mysql (Default user : root tanpa password) Mysql –u root –p
  • 10. Pengelolaan Database 1. Membuat Database 3. Memodifikasi Database Create Database [if not exists] <nama database> [[DEFAULT] Character Set <nama character set] [[DEFAULT] Collate <nama collation>] Alter Database <nama database> [[DEFAULT] Character Set <nama character set] [[DEFAULT] Collate <nama collation>] 4. Menghapus Database Drop Database [if exists] <nama database> Create Database TokoBuku; Alter Database TokoBuku Character set latin1; Drop Database IF EXISTS TokoBuku; 2. Menggunakan Database Use <nama database> Use TokoBuku;
  • 11. Pengelolaan Table Create Table <nama tabel> (<Elemen Tabel> ::= <definisi kolom) 1. Membuat Tabel 2. Menghapus Tabel Drop Table [if exists] <nama tabel> 3. Melihat Pembuatan Tabel Show Create Table <nama tabel>
  • 12. Pengelolaan Table Memodifikasi Tabel ALTER TABLE <nama tabel> MODIFY <nama kolom> <tipe data>) 1. Merubah Tipe Data Kolom 2. Merubah Nama Kolom ALTER TABLE <nama tabel> CHANGE <nama kolom lama> <nama kolom baru> <tipe data> RENAME TABLE <nama tabel lama> TO <nama tabel baru> 3. Merubah Nama Tabel 4. Menambah Kolom / Aksi Tabel ALTER TABLE <nama tabel > ADD <nama kolom> <tipe data> ALTER TABLE <nama tabel> DROP <nama kolom> 5. Menghapus Kolom Tabel
  • 13. Contoh Alter Table CREATE TABLE pembelian ( IDPembelian SMALLINT UNSIGNED NOT NULL PRIMARY KEY, IDModel SMALLINT UNSIGNED NOT NULL, DeskripsiModel VARCHAR(40) ); ALTER TABLE pembelian ADD UNIQUE KEY (IDModel); CREATE TABLE pembelian ( IDPembelian SMALLINT UNSIGNED NOT NULL, IDModel SMALLINT UNSIGNED, DeskripsiModel VARCHAR(40), PRIMARY KEY (IDPembelian), UNIQUE KEY (IDModel) );
  • 14. Contoh Alter Table CREATE TABLE pembelian ( IDPembelian SMALLINT UNSIGNED NOT NULL PRIMARY KEY, IDModel SMALLINT UNSIGNED NOT NULL, DeskripsiModel VARCHAR(40) ); CREATE TABLE pembelian ( IDPembelian SMALLINT UNSIGNED NOT NULL, IDModel SMALLINT UNSIGNED NOT NULL, DeskripsiModel VARCHAR(40), PRIMARY KEY (IDPembelian, IDModel) ); ALTER TABLE pembelian ADD PRIMARY KEY (IDModel); ALTER TABLE pembelian DROP PRIMARY KEY, ADD PRIMARY KEY (IDPembelian,IDModel);
  • 16. Contoh Alter Table ALTER TABLE katalog CHANGE IDProduk IDProduk SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT CREATE TABLE katalog( IDProduk SMALLINT UNSIGNED NOT NULL, Nama VARCHAR(40) NOT NULL, PRIMARY KEY (IDProduk) ); CREATE TABLE katalog( IDProduk SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, Nama VARCHAR(40) NOT NULL, PRIMARY KEY (IDProduk) ); ALTER TABLE katalog MODIFY IDProduk SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
  • 17. Contoh Alter Table CREATE TABLE model( IDModel SMALLINT UNSIGNED NOT NULL, Nama_Model VARCHAR(15) NOT NULL, Jenis_Model VARCHAR(15) NOT NULL, PRIMARY KEY (IDModel) ); CREATE TABLE pembelian ( IDPembelian SMALLINT UNSIGNED NOT NULL, IDModel SMALLINT UNSIGNED NOT NULL, DeskripsiModel VARCHAR(40), PRIMARY KEY (IDPembelian) ); CREATE TABLE pembelian ( IDPembelian SMALLINT UNSIGNED NOT NULL, IDModel SMALLINT UNSIGNED NOT NULL, DeskripsiModel VARCHAR(40), PRIMARY KEY (IDPembelian), FOREIGN KEY (IDModel) REFERENCES model(IDModel) ON DELETE RESTRICT / NO ACTION / CASCADE ON UPDATE RESTRICT / NO ACTION / CASCADE );