MYSQL

Member CPNS Kemdikbud
22 Jun 202316:51

Summary

TLDRThis video script offers an introduction to SQL, emphasizing the importance of understanding SQL queries for database management. It distinguishes between DDL (Data Definition Language) for creating and modifying database structures, and DML (Data Manipulation Language) for managing data within those structures. The script provides examples of SQL commands such as 'CREATE', 'ALTER', 'DROP', 'INSERT', 'UPDATE', and 'DELETE', illustrating their use in both practical and theoretical contexts. The goal is to equip viewers with the foundational knowledge needed to effectively interact with databases using SQL.

Takeaways

  • πŸ“š The speaker begins by explaining the importance of understanding SQL before using tools like PHP MyAdmin for database management.
  • πŸ” SQL is divided into two main types of queries: DDL (Data Definition Language) and DML (Data Manipulation Language).
  • πŸ›  DDL is used for creating, altering, and dropping database structures such as tables, while DML is for manipulating the data within those tables.
  • πŸ“ The speaker emphasizes that understanding SQL queries is crucial as they are used across all programming languages for database interactions.
  • πŸ—‚οΈ DDL includes specific commands like 'CREATE', 'ALTER', and 'DROP' to modify the structure of the database.
  • πŸ”‘ 'CREATE' is used to establish new databases or tables, 'ALTER' to modify them, and 'DROP' to remove them from the database.
  • πŸ“ˆ The script demonstrates how to create a table with a primary key and other columns, using 'CREATE TABLE' followed by the table's name and column specifications.
  • πŸ”„ 'ALTER TABLE' is used to add new columns to an existing table, as shown when the speaker wants to add a 'NIM' column to the 'TB Mahasiswa' table.
  • πŸ—‘οΈ 'DROP TABLE' is used to delete an entire table from the database, which is different from 'DELETE' which is part of DML and is used to remove specific records.
  • πŸ”„ DML includes 'INSERT' to add new records, 'UPDATE' to modify existing records, and 'DELETE' to remove specific entries from a table.
  • πŸ”Ž The speaker illustrates the use of 'INSERT' to add new student records to the 'TB Mahasiswa' table and 'UPDATE' to change a student's name.
  • πŸ“ The takeaway is that understanding the difference between DDL and DML is fundamental for anyone working with databases, as they serve different purposes in database management.

Q & A

  • What does SQL stand for and what is its primary purpose?

    -SQL stands for Structured Query Language. It is used for managing and manipulating databases, including creating, updating, and querying data.

  • What is the difference between DDL and DML in SQL?

    -DDL, or Data Definition Language, is used for defining and modifying the structure of a database, such as creating or altering tables. DML, or Data Manipulation Language, is used for manipulating the data within the database, such as inserting, updating, or deleting records.

  • What is the basic command to create a database in SQL?

    -The basic command to create a database in SQL is 'CREATE DATABASE database_name', where 'database_name' is the name you want to give to your database.

  • How do you create a table in SQL?

    -To create a table in SQL, you use the 'CREATE TABLE table_name' command followed by the definition of the columns and their data types, and any constraints such as PRIMARY KEY.

  • What is a primary key in a SQL table?

    -A primary key in a SQL table is a column or a set of columns that uniquely identify each row in the table. It enforces uniqueness and cannot contain NULL values.

  • What is the 'AUTO_INCREMENT' attribute used for in SQL?

    -The 'AUTO_INCREMENT' attribute in SQL is used for automatically incrementing the value of a column, typically a primary key, whenever a new record is inserted.

  • What command is used to add a new column to an existing table in SQL?

    -To add a new column to an existing table, you use the 'ALTER TABLE table_name ADD column_name data_type' command.

  • How can you delete a table in SQL?

    -You can delete a table in SQL using the 'DROP TABLE table_name' command, which removes the table and all its data.

  • What is the 'INSERT' command used for in SQL?

    -The 'INSERT' command in SQL is used to add new records to a table. It specifies the table and the values to be inserted into the specified columns.

  • What does the 'UPDATE' command do in SQL?

    -The 'UPDATE' command in SQL is used to modify existing records in a table. It allows you to change the data of one or more columns of a single row or multiple rows based on a specified condition.

  • What is the 'SELECT' command used for in SQL?

    -The 'SELECT' command in SQL is used to retrieve data from one or more tables. It allows you to specify the columns you want to view and the conditions for filtering the data.

  • How do you delete a specific record from a table in SQL?

    -To delete a specific record from a table, you use the 'DELETE FROM table_name WHERE condition' command, where 'condition' specifies which record(s) to delete, such as 'ID = 1'.

Outlines

00:00

πŸ“š Introduction to SQL and Query Types

This paragraph introduces the topic of SQL and its importance in database management systems. It emphasizes the need to understand SQL queries before using tools like PHP MyAdmin. The speaker explains the difference between DDL (Data Definition Language) and DML (Data Manipulation Language), which are essential for creating, modifying, and deleting database structures and data, respectively. DDL is used for creating databases and tables, while DML is for inserting, updating, and deleting data within those tables.

05:04

πŸ›  Creating Databases and Tables with DDL

The speaker delves into the specifics of using DDL to create databases and tables. They provide an example of creating a 'db_campus' database and a 'TB_mahasiswa' table, detailing the process of defining columns, including a primary key with auto-increment properties. The paragraph also covers how to use the 'CREATE TABLE' command and the importance of understanding the structure of a database before manipulating it.

10:05

πŸ”„ Modifying Database Structures with DDL

This section explains how to modify an existing database structure using DDL commands. The speaker discusses the 'ALTER TABLE' command, which allows users to add new columns to a table, such as 'NIM' to the 'TB_mahasiswa'. They also touch on the 'DROP TABLE' command, which is used to delete an entire table, but clarify that it does not delete the data within the table, only the table structure itself.

15:08

πŸ—‚ Manipulating Data with DML

The final paragraph focuses on DML, which is used for data manipulation within the database. The speaker outlines the basic DML commands: 'INSERT' for adding new records, 'DELETE' for removing data, and 'UPDATE' for modifying existing records. They provide examples of how to use these commands, such as inserting a new student record into the 'TB_mahasiswa' table and updating a student's name. The importance of understanding the difference between altering table structures with DDL and manipulating data with DML is reiterated.

Mindmap

Keywords

πŸ’‘SQL

SQL, which stands for Structured Query Language, is a standard language for managing and manipulating databases. In the video, it is the main topic being discussed, with the script explaining the basics of SQL and its importance in database management systems (DBMS). The script mentions SQL in the context of understanding queries and their functions, which is fundamental for anyone working with databases.

πŸ’‘Database Management System (DBMS)

A Database Management System is a software system that enables the management of databases. In the video, DBMS is mentioned as a platform where one can learn about SQL theoretically. The script suggests that while the theory can be learned from a DBMS, practical application requires understanding SQL queries, which is a key point in the video.

πŸ’‘DDL (Data Definition Language)

DDL is a subset of SQL used to define and modify the structure of a database, such as creating, altering, or dropping tables. The script explains DDL as the first type of SQL query, emphasizing its role in establishing the framework of a database, with examples like 'CREATE TABLE' and 'DROP TABLE'.

πŸ’‘DML (Data Manipulation Language)

DML is another subset of SQL that deals with the data within a database, allowing users to insert, update, delete, and retrieve data. The script contrasts DML with DDL, highlighting that while DDL is for structural changes, DML is for manipulating the actual data, with 'INSERT', 'UPDATE', and 'DELETE' being key commands.

πŸ’‘Primary Key

A primary key is a unique identifier for a record in a database table, ensuring that each row can be uniquely identified. In the script, the primary key is mentioned as the first column in a table, typically an integer with an auto-increment property, which is crucial for the table's structure.

πŸ’‘Auto Increment

Auto Increment is a property of a primary key column that automatically assigns an incremental value to new records. The script explains this concept by stating that the primary key will increase automatically with each new entry, which is essential for maintaining a unique identifier for each record.

πŸ’‘PHPMyAdmin

PHPMyAdmin is a free, open-source administration tool for MySQL databases. The script mentions PHPMyAdmin as a tool that can be used to open or create databases, suggesting that it is a practical application of the SQL concepts being discussed, providing a user interface for database management.

πŸ’‘Table

In the context of databases, a table is a collection of related data held in a structured format within a database. The script frequently refers to tables as the main entities where data is organized, with actions such as creating, modifying, and dropping tables being central to the discussion.

πŸ’‘Column

A column in a database table represents a field for the data, which can hold all information related to a specific attribute of the data. The script discusses columns in the context of defining table structures, such as adding a 'NIM' column to the 'TB mahasiswa' table as an example of modifying a table.

πŸ’‘Query

A query in SQL is a request for information from a database. The script emphasizes the importance of understanding queries, both for defining database structures (DDL) and for manipulating data (DML). Queries are the means by which one interacts with the database, as illustrated by the various SQL commands discussed.

Highlights

Introduction to SQL and its importance in database management systems (DBMS).

Explanation of the difference between SQL in theory and its practical application.

Suggestion to understand SQL basics before using tools like PHP MyAdmin.

Discussion on the universality of SQL queries across different programming languages.

Introduction to Data Definition Language (DDL) and its functions.

DDL's role in creating, altering, and dropping database structures.

Explanation of Data Manipulation Language (DML) and its operations.

DML's use in inserting, updating, and deleting data within a database.

The significance of understanding the difference between DDL and DML for database operations.

Detailed example of creating a database using the 'CREATE DATABASE' query.

Step-by-step guide on creating a table with the 'CREATE TABLE' statement.

Importance of primary keys and auto-increment in table structure.

Demonstration of adding a new column to an existing table using 'ALTER TABLE'.

How to delete a table structure using the 'DROP TABLE' statement.

Explanation of 'INSERT' query for adding new records to a database table.

Use of the 'UPDATE' statement to modify existing data within a table.

Clarification on the 'DELETE' statement for removing data from a table.

Emphasis on the necessity of knowing basic SQL queries for database management.

Encouragement for learners to practice creating and manipulating databases and tables.

Transcripts

play00:03

Oke Assalamualaikum warahmatullahi

play00:05

wabarakatuh

play00:07

kita

play00:15

Oke kita bakal lanjut materinya kemarin

play00:19

kan udah

play00:20

penjelasan tentang

play00:23

array function dan juga ya sekarang saya

play00:27

akan ngejelasin ke kalian tentang SQL

play00:29

jadi Mungkin kalian udah pernah belajar

play00:32

tentang SQL sama Bu Sari di dbms ya di

play00:36

database management system

play00:38

teorinya biasanya Nah untuk prakteknya

play00:41

sendiri kalian sebetulnya Kan bisa pakai

play00:43

PHP my admin

play00:45

kalau kalian mau buka atau mau bikin

play00:48

database kan kalian bisa pakai PHP naik

play00:51

addin ini ya ternyata sudah terbiasalah

play00:53

pakai ini tapi sebelum kalian pakai PHP

play00:57

lain ini saya sarankan kalian harus

play00:59

paham dulu tentang Apa itu SQL dan

play01:02

pembagian querynya dan fungsi-fungsi

play01:04

querynya buat apa Kenapa kayak gitu

play01:08

karena

play01:10

hampir di semua bahasa pemrograman itu

play01:13

kalau kalian loadingnya Pakai nasi atau

play01:15

prosedural itu querynya sama jadi query

play01:18

sda-nya sama misal Kalian mau pakai

play01:20

Python tapi masukin data ke database itu

play01:23

perintahnya sama kodenya sama di php

play01:26

Kalian mau apa mau masukin database ke

play01:32

SQL pakai bahasa pemrograman PHP query

play01:34

untuk masukin ke databasenya pun juga

play01:36

sama Begitu juga dengan Java si

play01:38

plus-plus atau yang lainnya Jadi kalian

play01:40

harus paham tentang query SQL

play01:44

oke di sini query SQL itu terbagi ke

play01:48

dalam tiga tapi saya akan bahasnya dua

play01:50

yaitu DDL dan juga

play01:53

DDL ini singkatan dari data definition

play01:59

Sedangkan dml ini singkatan dari

play02:10

Kedua jenis query ini nantinya akan

play02:14

mempunyai perintah-perintah

play02:17

sendiri contohnya Ini data definition

play02:20

language ini biasanya querynya digunakan

play02:22

untuk kalian bikin struktur database

play02:25

misal kalian bikin database kalian bikin

play02:27

tabel dan juga feel feelsnya Kalian mau

play02:30

modifikasi table Kalian mau hapus table

play02:35

atau ngehapus kolom Nah itu kalian pakai

play02:38

DDL ingat menghapus table bukan

play02:40

menghapus isi table sedangkan kalau

play02:43

kalian ngobrolin dml atau data

play02:46

manipulation language Ini adalah yang

play02:48

berhubungan dengan

play02:51

isiannya atau recordnya atau value bisa

play02:54

kalian Mau insert data ke dalam tabel ke

play02:58

dalam table berarti querynya pakainya

play03:00

DNA atau Kalian mau update data mau ubah

play03:03

data mau edit data itu kalian pakainya

play03:06

verynya DNA atau Kalian mau hapus

play03:08

datanya untuk kalian sharingnya juga

play03:11

pakai DNA Jadi kalau DDL untuk

play03:15

memodifikasi tambah dan hapus tabel tapi

play03:18

kalau dml untuk

play03:20

menambah edit hapus data tabel Beda ya

play03:24

ada tabelnya ada datanya jadi itu

play03:27

perbedaan dari DDL dan

play03:35

Nah untuk

play03:38

DDL ini querynya ada 3 bisa kalian

play03:41

singkat cad kayaknya itu create a nya

play03:45

itu Alter d nya itu drop jadi ada tiga

play03:49

query ini yang kalian bisa gunakan untuk

play03:51

fungsi tadi data definition language

play03:54

atau memodifikasi menambah mengubah dan

play03:56

menghapus sebuah table dan strukturnya

play03:59

contoh

play04:02

Kalian mau membuat satu buah table

play04:18

Oke tadi create order dan drop ini untuk

play04:23

memodifikasi delete dan juga tambah

play04:26

tabel ya contohnya kalau kalian mau

play04:29

bikin database berarti querynya ingat

play04:32

create ya mau bikin database

play04:38

DB kampus jadi nama databasenya

play04:43

db_campus ini query wajib Create

play04:46

database ini tuh query wajib jadi Create

play04:49

database kalian akan membuat sebuah

play04:50

database dengan nama databasenya adalah

play04:54

contohnya lagi kalau kalian mau bikin

play04:57

tabel

play04:59

berarti create tabel nah ini ini query

play05:03

wajib create tabel karena kita akan

play05:05

bikin data tabel gitu terus nama

play05:07

tabelnya apa misalnya TB mahasiswa

play05:10

tapi ini nggak kalau kalian kayak gini

play05:13

doang berarti sih tabelnya nggak akan

play05:14

ada kolom di dalamnya jadi kayak tabel

play05:17

mahasiswa aja udah di dalamnya nggak ada

play05:19

apa-apa kan kita harus bikin kolom atau

play05:21

pil ya Apakah di sini kita sebutkan

play05:24

biasanya yang menjadi kolom pertama

play05:27

adalah primary dari sebuah table

play05:31

biasanya tipe datanya integer dan dia

play05:34

akan menjadi primary

play05:39

dan juga dia akan menjadi atau akan

play05:42

bersifat auto enter

play05:49

ini kita coba langsung deh ya

play05:56

terus misalnya kolom keduanya adalah

play05:58

nama

play06:03

kayak gini ya Misalnya ada tabel ini

play06:06

kita coba langsung bikin deh

play06:08

supaya terlihat Apa betul atau tidaknya

play06:11

kita langsung di sini bikin

play06:12

bikin apa yang baru ini aja SQL jadi ini

play06:17

fungsi diri PHP sama admin kalau kalian

play06:19

mau langsung coding jadi nggak kan kalau

play06:22

bikin tabel eh bikin database cara klik

play06:24

kan kalian tinggal klik menu terus

play06:27

masukin nama databasenya apa terus ini

play06:28

create tapi kalau kalian mau pakainya

play06:31

query ini kalian bisa tulis di sini

play06:34

verynya misalnya tadi Create database

play06:38

db kampus nah ini kalian tinggal klik go

play06:42

ini pasti langsung

play06:45

dia udah langsung terbuat dari

play06:48

nah ketika Kalian mau bikin tabel di

play06:51

dalam diri kampus kalau mau klik-klik

play06:53

Kalian kan udah pasti udah biasa lah ya

play06:55

masukin nama tabelnya terus kalau

play06:57

misalnya ada berapa Terus klik cream

play06:59

nanti masukin virus-virusnya apa saja

play07:01

Tapi kalau pakai query Jadi kalian bisa

play07:04

pakai yang ini

play07:06

kita masukkan dulu ke

play07:10

workspacenya

play07:12

create tabel nama tabelnya apa fill

play07:15

pertama adalah ID dengan tipe datanya

play07:18

integer dia sifatnya adalah primary atau

play07:20

statusnya adalah kunci utama dan dia

play07:24

bersifat auto incrament jadi dia akan

play07:27

menambah otomatis lalu field kedua

play07:30

adalah nama tipe datanya adalah

play07:34

250.000 kita coba klik dulu

play07:39

udah selesai masuk ke tabel mahasiswa

play07:44

kita lihat di struktur ini sudah ada dua

play07:46

kolom yaitu id dan nama dengan id-nya

play07:49

ini statusnya adalah primary ini ada

play07:51

kuncinya di sini dan juga ada Auto

play07:56

[Musik]

play07:58

Nah selanjutnya

play08:00

ini kita bisa

play08:04

misal mau ada tambahan feel plain kalau

play08:07

mau ada tambahan film lain berarti kita

play08:09

kan akan memodifikasi database atau

play08:12

memodifikasi isi table dari database

play08:16

kita tambahkan

play08:19

caranya adalah pakai query

play08:24

Nah tadi kan

play08:26

kalian masih ingat kan ada masih ingat

play08:31

kan tadi ada DDL dan DM kalau DDL itu

play08:34

buat struktur kalau dmar itu buat

play08:37

datanya atau berikutnya Nah karena kita

play08:39

kan memanipulasi sebuah struktur tabel

play08:41

maka yang kita pakai adalah DDL bukan

play08:45

dml bukan kalau kalian pernah ingat ada

play08:47

update

play08:48

tabel apa insert apa

play08:51

tapi kalian harus pakainya itu query

play08:55

yang cad entah itu

play08:58

kan

play08:59

drop berarti kalian pakai untuk

play09:01

memodifikasinya itu pakai query namanya

play09:03

Albab fungsinya gimana misalnya kan ini

play09:06

kan tabel mahasiswa ada dua kolom ya ada

play09:09

ID sama Nama misalnya kita mau tambahkan

play09:13

NIM misalnya ya

play09:17

ini adalah kolom baru berarti kan kita

play09:19

mau memodifikasi sebuah tabel caranya

play09:22

pakai fungsi Alter

play09:25

eltar nama tabelnya apa alternabelle

play09:28

Alter tabel TB mahasiswa misalnya mau

play09:32

kita tambahin kolom baru berarti add Apa

play09:35

nama kolomnya misalnya NIM terus

play09:39

255 nah ini inget ini ada fungsi Alter

play09:43

Alter tabel ini tabelnya disebutkan ya

play09:48

sebuah kolom kolomnya adalah NIM tipe

play09:51

datanya adalah kita klik dulu maka dia

play09:54

akan langsung menambah jadi ada tiga

play10:01

yang terakhir adalah drop drop ini

play10:04

fungsinya untuk menghapus misalnya

play10:06

Kalian mau menghapus tabel mahasiswa ini

play10:08

maka kalian akan pakai

play10:13

ini saya nanti udah capek-capek ini lagi

play10:19

kita bikin tabel baru aja

play10:30

tapi di sini nggak akan saya isi ya

play10:32

karena saya mau langsung

play10:44

tabel TB dosen id

play10:51

dah nggak bisa kalau nggak ada kolam

play10:53

ternyata klik go Ini kan udah ada nih

play10:56

tabel dosen nah misalnya mau kita hapus

play10:59

bukan delete Ya karena delete itu

play11:01

fungsinya ada di chip ada di Dede yang

play11:03

ada di dml ini kalau D ini adalah drop

play11:06

ya berarti querynya adalah

play11:09

langsung drop

play11:12

tabel tadi

play11:15

[Musik]

play11:30

Nah selanjutnya ada yang namanya dml

play11:33

data manipulation language data

play11:36

manipulation language Ini kita gunakan

play11:38

untuk memodifikasi

play11:40

menambah

play11:42

mendelete merubah

play11:47

isi atau record atau data

play11:50

darinya itu bisa singkat sih

play11:53

untuk memanggil atau mau menampilkan

play11:56

Insert untuk menambahkan delete untuk

play11:59

menghapus dan update untuk mengupdate

play12:02

atau mengubah isi datanya

play12:05

select delete update

play12:08

ya Nah apa sih contohnya contohnya di

play12:11

sini kan udah ada tabel mahasiswa dengan

play12:14

isi kolom atau isi fieldnya ada ID nama

play12:19

Danny ini struktur ya Id nama dan ini

play12:22

adalah struktur lalu akan kita misal

play12:26

tambahkan misal ya kita akan tambahkan

play12:29

datanya misalnya id-nya misalnya

play12:35

[Musik]

play12:43

ini di sini kan

play13:01

tabel mahasiswa ada kolomnya apa aja Nah

play13:06

karena tadi kita isi ini sih bagian

play13:08

id-nya dan di autentik

play13:18

kita lihat browse dulu harusnya udah ada

play13:20

datanya Tuh udah ada idenya satu

play13:22

jangan-jangan jadi yang dml ini

play13:25

fungsinya Untuk memanipulasi

play13:27

isi datanya contoh nih ya kita mau

play13:31

tambahin selain Diana berarti Insert ini

play13:34

kita hapus

play13:36

ini kita klik ulang aja sebetulnya

play13:38

kalian bisa Klik yang bawah sini

play13:41

nah kalau yang ini gak dipanggil ya

play13:43

kata-kata table-nya kalau tadi kan

play13:45

Create database DB kampus kriya table PB

play13:48

mahasiswa Nah sekarang tuh kalau di

play13:50

Insert nggak

play13:51

tapi langsung Insert nama tabelnya apa

play13:55

lalu masukkan si valuesnya Harusnya sih

play13:58

ID nggak perlu disebutin kita sebutin

play14:01

aja nama danin Kenapa karena kan id-nya

play14:04

udah pasti kita coba dulu

play14:08

sekarang versi terbaru Apakah bisa nggak

play14:11

disebutin

play14:12

Misalnya ini adalah

play14:15

Marco

play14:21

tabel mahasiswa

play14:29

tabel tabel

play14:42

itu yang Insert kalau select kalian udah

play14:45

gak perlu dijelasin lagi sekarang kalau

play14:47

mau ngubah isi datanya kalau tadi kan

play14:48

mengubah isi mengubah tabel atau

play14:50

mengubah file itu pakai Alter ya kalau

play14:53

ini kan kita misalnya mau mengubah atau

play14:55

modifikasi

play14:56

PC atau data dari table pakai apa kalian

play15:00

bisa pakai fungsi

play15:08

kalian bisa pakai ini tadi misalnya

play15:10

Marco mau kita tambahin jadi ini

play15:14

mahasiswa

play15:19

set nama

play15:39

yang tadinya Marco doang pasti jadi

play15:44

seperti itu contohnya dari dml ini

play15:47

kalian harus ingat ya ini kan

play15:50

terus yang terakhir delete kalau delete

play15:54

sih gampang misalnya gini

play15:59

where ID = 1 berarti yang jaraknya

play16:05

nggak ada bintang ya delete

play16:08

karena ada where

play16:11

nggak ada nih

play16:16

tuh itu ya Kesimpulannya adalah ada dua

play16:20

query penting yang harus kalian pahami

play16:22

di SQL DDL dan DMS sebetulnya masih

play16:24

banyak lagi tapi ini untuk basicnya

play16:26

kalian harus tau bedanya kalau kalian

play16:29

mau mengubah table atau mau mengubah isi

play16:31

Table mau nambahin kolom atau mau

play16:36

nambahin isi dari kolom itu kalian harus

play16:38

tau beda perbedaan oke

play16:43

dicoba dulu aja sama kalian bikin kayak

play16:45

gini mirip kayak yang saya

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
SQLDDLDMLDatabaseManagementDataTutorialProgrammingPHPMySQLEducation