🔥 และในวันนี้ แอดจะพาเพื่อน ๆ มาทำความรู้จักกับอีกหนึ่งคำสั่งเจ๋ง ๆ ใน SQL นั่นก็คือเจ้า EXPLAIN นั่นเองจ้าาา ~~
.
👉 เจ้านี่มันคืออะไร มีรายละเอียดและวิธีการใช้งานยังไง ถ้าพร้อมแล้วมาอ่านกันเลยยย !!
.
✨ EXPLAIN - เป็นคำสั่งที่ใช้บอกรายละเอียดในการ Query ข้อมูล เพื่อใช้วัดประสิทธิภาพในการ Query ข้อมูลนั่นเอง
.
👨💻 Syntax
EXPLAIN (QUERY Statement) ; /* ONLY TAKES COMMAND AS PARAMETER */
.
เจ้า EXPLAIN สามารถใช้นำหน้าคำสั่ง SELECT, UPDATE, INSERT และ DELETE ได้
.
📑 วิธีการใช้งาน
🔸 Query ปกติ
SELECT * FROM demo_table WHERE demo_column = 'Demo Value';
.
🔸 Query โดยใช้ EXPLAIN
EXPLAIN SELECT * FROM demo_table WHERE demo_column = 'Demo Value';
.
จะได้ผลลัพธ์ ดังนี้
id: 1
select_type: SIMPLE
table: demo_table
partitions: NULL
type: const
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: const
rows: 1
filtered: 100.00
Extra: NULL
.
🔸 id - id ของ Query EXPLAIN
🔸 select_type - แสดงความซับซ้อนของ Query ผลลัพธ์ด้านบนจะอยู่ในระดับ SIMPLE
🔸 table - แสดงชื่อของตาราง
🔸 partitions - แสดง Partitions ของตารางที่ใช้ใน Query
🔸 type - ระบุประเภทของการ Join
🔸 possible_keys - แสดง Key ที่ใช้
🔸 key - แสดงความยาวของ Key ที่ใช้
🔸 ref - การอ้างอิงที่ใช้ใน Query เมื่อทำการ Comparing Columns
🔸 rows - แสดงจำนวนแถว
🔸 filtered - แสดงเปอร์เซ็นต์ของแถวตามเงื่อนไขที่ระบุ
🔸 Extra - ข้อมูลเพิ่มเติมของ Query
.
🌟 ประโยชน์
- ใช้เพื่อแสดงข้อมูลเกี่ยวกับการ Query
- มีประโยชน์มากในการออกแบบ Schema และ Index
- ใช้ตรวจสอบคำสั่ง Query ว่ามีประสิทธิภาพหรือไม่ เช่น วัดความเร็วในการ Query, ตรวจสอบการแบ่ง - Partition ของตาราง เป็นต้น
- ช่วยเพิ่มประสิทธิภาพในการ Query ข้อมูลใน Database
.
💥 Source : https://arctype.hashnode.dev/mysql-understanding-explain , https://www.geeksforgeeks.org/explain-in-sql/
.
borntoDev - 🦖 สร้างการเรียนรู้ที่ดีสำหรับสายไอทีในทุกวัน
同時也有17部Youtube影片,追蹤數超過12萬的網紅prasertcbs,也在其Youtube影片中提到,-- command create user alpha with encrypted password '1234'; \c demo grant select on table public.benjerry to alpha; grant select, insert, update, del...
「insert mysql」的推薦目錄:
- 關於insert mysql 在 BorntoDev Facebook 的精選貼文
- 關於insert mysql 在 prasertcbs Youtube 的精選貼文
- 關於insert mysql 在 prasertcbs Youtube 的最佳解答
- 關於insert mysql 在 prasertcbs Youtube 的最佳貼文
- 關於insert mysql 在 How can I do 'insert if not exists' in MySQL? - Stack Overflow 的評價
- 關於insert mysql 在 Insert Statement Take too long to insert - MYSQL - DBA ... 的評價
- 關於insert mysql 在 MySQL - Add Records and Search Tables (insert, select) 的評價
insert mysql 在 prasertcbs Youtube 的精選貼文
-- command
create user alpha with encrypted password '1234';
\c demo
grant select on table public.benjerry to alpha;
grant select, insert, update, delete on table public.menu to alpha;
grant select, insert, update, delete on all tables in schema public to alpha;
revoke all privileges on all tables in schema public from alpha;
grant all privileges on all tables in schema public to alpha;
ดาวน์โหลด saturn database (saturn.tar) ได้ที่ ► http://bit.ly/2E2uY7a
เชิญสมัครเป็นสมาชิกของช่องนี้ได้ที่ ► https://www.youtube.com/subscription_center?add_user=prasertcbs
สอน PostgreSQL ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGi_NqmIu43B-PsxA0wtnyH
สอน MySQL ► https://www.youtube.com/playlist?list=PLoTScYm9O0GFmJDsZipFCrY6L-0RrBYLT
สอน Microsoft SQL Server 2012, 2014, 2016, 2017 ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH8gYuxpp-jqu5Blc7KbQVn
สอน SQLite ► https://www.youtube.com/playlist?list=PLoTScYm9O0GHjYJA4pfG38M5BcrWKf5s2
สอน SQL สำหรับ Data Science ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGq8M6HO8xrpkaRhvEBsQhw
การเชื่อมต่อกับฐานข้อมูล (SQL Server, MySQL, SQLite) ด้วย Python ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEdZtHwU3t9k3dBAlxYoq59
การใช้ Excel ในการทำงานร่วมกับกับฐานข้อมูล (SQL Server, MySQL, Access) ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGA2sSqNRSXlw0OYuCfDwYk
#prasertcbs_SQL #prasertcbs #prasertcbs_PostgreSQL

insert mysql 在 prasertcbs Youtube 的最佳解答
script สำหรับสร้างตาราง sales;
drop table if exists sales;
create table sales (
branch text,
dt date,
revenue int,
primary key (branch, dt)
);
insert into sales
select 'bangkok' branch, dt::date, (10000 + random() * 20000)::int revenue
from generate_series('2018-01-01'::date, '2019-12-31'::date, '1 day') dt
UNION
select 'phuket' branch, dt::date, (10000 + random() * 10000)::int revenue
from generate_series('2018-01-01'::date, '2019-12-31'::date, '1 day') dt
order by branch, dt;
ดาวน์โหลด PostgreSQL script ไฟล์ที่ใช้ในคลิปได้ที่ ► http://bit.ly/2mdDVmm
ดาวน์โหลด saturn database (saturn.tar) ได้ที่ ► http://bit.ly/2E2uY7a
เชิญสมัครเป็นสมาชิกของช่องนี้ได้ที่ ► https://www.youtube.com/subscription_center?add_user=prasertcbs
สอน PostgreSQL ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGi_NqmIu43B-PsxA0wtnyH
สอน MySQL ► https://www.youtube.com/playlist?list=PLoTScYm9O0GFmJDsZipFCrY6L-0RrBYLT
สอน Microsoft SQL Server 2012, 2014, 2016, 2017 ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH8gYuxpp-jqu5Blc7KbQVn
สอน SQLite ► https://www.youtube.com/playlist?list=PLoTScYm9O0GHjYJA4pfG38M5BcrWKf5s2
สอน SQL สำหรับ Data Science ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGq8M6HO8xrpkaRhvEBsQhw
การเชื่อมต่อกับฐานข้อมูล (SQL Server, MySQL, SQLite) ด้วย Python ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEdZtHwU3t9k3dBAlxYoq59
การใช้ Excel ในการทำงานร่วมกับกับฐานข้อมูล (SQL Server, MySQL, Access) ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGA2sSqNRSXlw0OYuCfDwYk
#prasertcbs_SQL #prasertcbs #prasertcbs_PostgreSQL

insert mysql 在 prasertcbs Youtube 的最佳貼文
ดาวน์โหลด PostgreSQL script ไฟล์ที่ใช้ในคลิปได้ที่ ► http://bit.ly/2H9n1fx
ดาวน์โหลด saturn database (saturn.tar) ได้ที่ ► http://bit.ly/2E2uY7a
เชิญสมัครเป็นสมาชิกของช่องนี้ได้ที่ ► https://www.youtube.com/subscription_center?add_user=prasertcbs
สอน PostgreSQL ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGi_NqmIu43B-PsxA0wtnyH
สอน MySQL ► https://www.youtube.com/playlist?list=PLoTScYm9O0GFmJDsZipFCrY6L-0RrBYLT
สอน Microsoft SQL Server 2012, 2014, 2016, 2017 ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH8gYuxpp-jqu5Blc7KbQVn
สอน SQLite ► https://www.youtube.com/playlist?list=PLoTScYm9O0GHjYJA4pfG38M5BcrWKf5s2
สอน SQL สำหรับ Data Science ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGq8M6HO8xrpkaRhvEBsQhw
การเชื่อมต่อกับฐานข้อมูล (SQL Server, MySQL, SQLite) ด้วย Python ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEdZtHwU3t9k3dBAlxYoq59
การใช้ Excel ในการทำงานร่วมกับกับฐานข้อมูล (SQL Server, MySQL, Access) ► https://www.youtube.com/playlist?list=PLoTScYm9O0GGA2sSqNRSXlw0OYuCfDwYk
#prasertcbs_SQL #prasertcbs #prasertcbs_PostgreSQL

insert mysql 在 Insert Statement Take too long to insert - MYSQL - DBA ... 的推薦與評價
The table is MyISAM. You should really switch to InnoDB. If something taking 14.7 (or more) seconds touches that table, then writes can occur until it ... ... <看更多>
insert mysql 在 MySQL - Add Records and Search Tables (insert, select) 的推薦與評價

MySQL - Add Records and Search Tables (insert, select) ... Setup MySQL Lab: show databases; create ... ... <看更多>
insert mysql 在 How can I do 'insert if not exists' in MySQL? - Stack Overflow 的推薦與評價
... <看更多>