MYSQL
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
π 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.
π 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.
π 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.
π 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
π‘Database Management System (DBMS)
π‘DDL (Data Definition Language)
π‘DML (Data Manipulation Language)
π‘Primary Key
π‘Auto Increment
π‘PHPMyAdmin
π‘Table
π‘Column
π‘Query
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
Oke Assalamualaikum warahmatullahi
wabarakatuh
kita
Oke kita bakal lanjut materinya kemarin
kan udah
penjelasan tentang
array function dan juga ya sekarang saya
akan ngejelasin ke kalian tentang SQL
jadi Mungkin kalian udah pernah belajar
tentang SQL sama Bu Sari di dbms ya di
database management system
teorinya biasanya Nah untuk prakteknya
sendiri kalian sebetulnya Kan bisa pakai
PHP my admin
kalau kalian mau buka atau mau bikin
database kan kalian bisa pakai PHP naik
addin ini ya ternyata sudah terbiasalah
pakai ini tapi sebelum kalian pakai PHP
lain ini saya sarankan kalian harus
paham dulu tentang Apa itu SQL dan
pembagian querynya dan fungsi-fungsi
querynya buat apa Kenapa kayak gitu
karena
hampir di semua bahasa pemrograman itu
kalau kalian loadingnya Pakai nasi atau
prosedural itu querynya sama jadi query
sda-nya sama misal Kalian mau pakai
Python tapi masukin data ke database itu
perintahnya sama kodenya sama di php
Kalian mau apa mau masukin database ke
SQL pakai bahasa pemrograman PHP query
untuk masukin ke databasenya pun juga
sama Begitu juga dengan Java si
plus-plus atau yang lainnya Jadi kalian
harus paham tentang query SQL
oke di sini query SQL itu terbagi ke
dalam tiga tapi saya akan bahasnya dua
yaitu DDL dan juga
DDL ini singkatan dari data definition
Sedangkan dml ini singkatan dari
Kedua jenis query ini nantinya akan
mempunyai perintah-perintah
sendiri contohnya Ini data definition
language ini biasanya querynya digunakan
untuk kalian bikin struktur database
misal kalian bikin database kalian bikin
tabel dan juga feel feelsnya Kalian mau
modifikasi table Kalian mau hapus table
atau ngehapus kolom Nah itu kalian pakai
DDL ingat menghapus table bukan
menghapus isi table sedangkan kalau
kalian ngobrolin dml atau data
manipulation language Ini adalah yang
berhubungan dengan
isiannya atau recordnya atau value bisa
kalian Mau insert data ke dalam tabel ke
dalam table berarti querynya pakainya
DNA atau Kalian mau update data mau ubah
data mau edit data itu kalian pakainya
verynya DNA atau Kalian mau hapus
datanya untuk kalian sharingnya juga
pakai DNA Jadi kalau DDL untuk
memodifikasi tambah dan hapus tabel tapi
kalau dml untuk
menambah edit hapus data tabel Beda ya
ada tabelnya ada datanya jadi itu
perbedaan dari DDL dan
Nah untuk
DDL ini querynya ada 3 bisa kalian
singkat cad kayaknya itu create a nya
itu Alter d nya itu drop jadi ada tiga
query ini yang kalian bisa gunakan untuk
fungsi tadi data definition language
atau memodifikasi menambah mengubah dan
menghapus sebuah table dan strukturnya
contoh
Kalian mau membuat satu buah table
Oke tadi create order dan drop ini untuk
memodifikasi delete dan juga tambah
tabel ya contohnya kalau kalian mau
bikin database berarti querynya ingat
create ya mau bikin database
DB kampus jadi nama databasenya
db_campus ini query wajib Create
database ini tuh query wajib jadi Create
database kalian akan membuat sebuah
database dengan nama databasenya adalah
contohnya lagi kalau kalian mau bikin
tabel
berarti create tabel nah ini ini query
wajib create tabel karena kita akan
bikin data tabel gitu terus nama
tabelnya apa misalnya TB mahasiswa
tapi ini nggak kalau kalian kayak gini
doang berarti sih tabelnya nggak akan
ada kolom di dalamnya jadi kayak tabel
mahasiswa aja udah di dalamnya nggak ada
apa-apa kan kita harus bikin kolom atau
pil ya Apakah di sini kita sebutkan
biasanya yang menjadi kolom pertama
adalah primary dari sebuah table
biasanya tipe datanya integer dan dia
akan menjadi primary
dan juga dia akan menjadi atau akan
bersifat auto enter
ini kita coba langsung deh ya
terus misalnya kolom keduanya adalah
nama
kayak gini ya Misalnya ada tabel ini
kita coba langsung bikin deh
supaya terlihat Apa betul atau tidaknya
kita langsung di sini bikin
bikin apa yang baru ini aja SQL jadi ini
fungsi diri PHP sama admin kalau kalian
mau langsung coding jadi nggak kan kalau
bikin tabel eh bikin database cara klik
kan kalian tinggal klik menu terus
masukin nama databasenya apa terus ini
create tapi kalau kalian mau pakainya
query ini kalian bisa tulis di sini
verynya misalnya tadi Create database
db kampus nah ini kalian tinggal klik go
ini pasti langsung
dia udah langsung terbuat dari
nah ketika Kalian mau bikin tabel di
dalam diri kampus kalau mau klik-klik
Kalian kan udah pasti udah biasa lah ya
masukin nama tabelnya terus kalau
misalnya ada berapa Terus klik cream
nanti masukin virus-virusnya apa saja
Tapi kalau pakai query Jadi kalian bisa
pakai yang ini
kita masukkan dulu ke
workspacenya
create tabel nama tabelnya apa fill
pertama adalah ID dengan tipe datanya
integer dia sifatnya adalah primary atau
statusnya adalah kunci utama dan dia
bersifat auto incrament jadi dia akan
menambah otomatis lalu field kedua
adalah nama tipe datanya adalah
250.000 kita coba klik dulu
udah selesai masuk ke tabel mahasiswa
kita lihat di struktur ini sudah ada dua
kolom yaitu id dan nama dengan id-nya
ini statusnya adalah primary ini ada
kuncinya di sini dan juga ada Auto
[Musik]
Nah selanjutnya
ini kita bisa
misal mau ada tambahan feel plain kalau
mau ada tambahan film lain berarti kita
kan akan memodifikasi database atau
memodifikasi isi table dari database
kita tambahkan
caranya adalah pakai query
Nah tadi kan
kalian masih ingat kan ada masih ingat
kan tadi ada DDL dan DM kalau DDL itu
buat struktur kalau dmar itu buat
datanya atau berikutnya Nah karena kita
kan memanipulasi sebuah struktur tabel
maka yang kita pakai adalah DDL bukan
dml bukan kalau kalian pernah ingat ada
update
tabel apa insert apa
tapi kalian harus pakainya itu query
yang cad entah itu
kan
drop berarti kalian pakai untuk
memodifikasinya itu pakai query namanya
Albab fungsinya gimana misalnya kan ini
kan tabel mahasiswa ada dua kolom ya ada
ID sama Nama misalnya kita mau tambahkan
NIM misalnya ya
ini adalah kolom baru berarti kan kita
mau memodifikasi sebuah tabel caranya
pakai fungsi Alter
eltar nama tabelnya apa alternabelle
Alter tabel TB mahasiswa misalnya mau
kita tambahin kolom baru berarti add Apa
nama kolomnya misalnya NIM terus
255 nah ini inget ini ada fungsi Alter
Alter tabel ini tabelnya disebutkan ya
sebuah kolom kolomnya adalah NIM tipe
datanya adalah kita klik dulu maka dia
akan langsung menambah jadi ada tiga
yang terakhir adalah drop drop ini
fungsinya untuk menghapus misalnya
Kalian mau menghapus tabel mahasiswa ini
maka kalian akan pakai
ini saya nanti udah capek-capek ini lagi
kita bikin tabel baru aja
tapi di sini nggak akan saya isi ya
karena saya mau langsung
tabel TB dosen id
dah nggak bisa kalau nggak ada kolam
ternyata klik go Ini kan udah ada nih
tabel dosen nah misalnya mau kita hapus
bukan delete Ya karena delete itu
fungsinya ada di chip ada di Dede yang
ada di dml ini kalau D ini adalah drop
ya berarti querynya adalah
langsung drop
tabel tadi
[Musik]
Nah selanjutnya ada yang namanya dml
data manipulation language data
manipulation language Ini kita gunakan
untuk memodifikasi
menambah
mendelete merubah
isi atau record atau data
darinya itu bisa singkat sih
untuk memanggil atau mau menampilkan
Insert untuk menambahkan delete untuk
menghapus dan update untuk mengupdate
atau mengubah isi datanya
select delete update
ya Nah apa sih contohnya contohnya di
sini kan udah ada tabel mahasiswa dengan
isi kolom atau isi fieldnya ada ID nama
Danny ini struktur ya Id nama dan ini
adalah struktur lalu akan kita misal
tambahkan misal ya kita akan tambahkan
datanya misalnya id-nya misalnya
[Musik]
ini di sini kan
tabel mahasiswa ada kolomnya apa aja Nah
karena tadi kita isi ini sih bagian
id-nya dan di autentik
kita lihat browse dulu harusnya udah ada
datanya Tuh udah ada idenya satu
jangan-jangan jadi yang dml ini
fungsinya Untuk memanipulasi
isi datanya contoh nih ya kita mau
tambahin selain Diana berarti Insert ini
kita hapus
ini kita klik ulang aja sebetulnya
kalian bisa Klik yang bawah sini
nah kalau yang ini gak dipanggil ya
kata-kata table-nya kalau tadi kan
Create database DB kampus kriya table PB
mahasiswa Nah sekarang tuh kalau di
Insert nggak
tapi langsung Insert nama tabelnya apa
lalu masukkan si valuesnya Harusnya sih
ID nggak perlu disebutin kita sebutin
aja nama danin Kenapa karena kan id-nya
udah pasti kita coba dulu
sekarang versi terbaru Apakah bisa nggak
disebutin
Misalnya ini adalah
Marco
tabel mahasiswa
tabel tabel
itu yang Insert kalau select kalian udah
gak perlu dijelasin lagi sekarang kalau
mau ngubah isi datanya kalau tadi kan
mengubah isi mengubah tabel atau
mengubah file itu pakai Alter ya kalau
ini kan kita misalnya mau mengubah atau
modifikasi
PC atau data dari table pakai apa kalian
bisa pakai fungsi
kalian bisa pakai ini tadi misalnya
Marco mau kita tambahin jadi ini
mahasiswa
set nama
yang tadinya Marco doang pasti jadi
seperti itu contohnya dari dml ini
kalian harus ingat ya ini kan
terus yang terakhir delete kalau delete
sih gampang misalnya gini
where ID = 1 berarti yang jaraknya
nggak ada bintang ya delete
karena ada where
nggak ada nih
tuh itu ya Kesimpulannya adalah ada dua
query penting yang harus kalian pahami
di SQL DDL dan DMS sebetulnya masih
banyak lagi tapi ini untuk basicnya
kalian harus tau bedanya kalau kalian
mau mengubah table atau mau mengubah isi
Table mau nambahin kolom atau mau
nambahin isi dari kolom itu kalian harus
tau beda perbedaan oke
dicoba dulu aja sama kalian bikin kayak
gini mirip kayak yang saya
Browse More Related Video
L4 : Types of SQL Commands | Complete SQL Course 2024 | Jobs | Placements
SQL and its History - Structured Query Language | Class 12 Computer Science Chapter 9 | CBSE 2024-25
Oracle interview Question : what is trigger in oracle
Dream Report: Acquiring Data from SQL Server
SQL Basics for Beginners | Learn SQL | SQL Tutorial for Beginners | Edureka
Complete CRUD Operation in Asp.Net C# With SQL Server Step by Step
5.0 / 5 (0 votes)