Back to Browse

SQL DML & DDL Commands Explained | Insert, Update, Delete, Truncate, Drop

105 views
Jul 28, 2024
11:59

In this video, we break down essential SQL DML (Data Manipulation Language) and DDL (Data Definition Language) commands to help you manage and manipulate your database effectively. We cover: - **Insert**: Adding new records to a table. - **Update**: Modifying existing records. - **Delete**: Removing specific records. - **Truncate**: Quickly clearing all records from a table. - **Drop**: Completely removing a table from the database. 🔍 **In This Video:** 1. Creating and inserting data into the `hospitals` table. 2. Using `UPDATE` to modify records. 3. Differentiating between `DELETE` and `TRUNCATE` commands. 4. Dropping the table when it's no longer needed. **Key Differences**: - `DELETE` vs. `TRUNCATE`: When to use which and why. `DELETE` can remove specific records or all records, while `TRUNCATE` is a fast way to remove all data. drop table if exists hospitals; create table hospitals ( hospital_code int , hospital_name varchar(50) , location varchar(200), contact_no bigint, constraint pk_hospitals primary key (hospital_code,hospital_name) ); --insert insert into hospitals values (1, 'Fortis Hospital', 'Bangalore', 9900099000); insert into hospitals values (2, 'Manipal Hospital', 'Manipal', 9900099222); insert into hospitals values (3, 'Apollo Hospital', 'Mumbai', 9900099333); insert into hospitals values (4, 'St. Francis Hospital', 'New York', 17194440001); insert into hospitals values (4, 'Duke Hospital', 'New York', 17194440022); select * from hospitals; -- UPDATE update hospitals set hospital_code=50 where hospital_name='Duke Hospital'; update hospitals set hospital_code=50, location='Wahsington DC' where hospital_name='Duke Hospital'; select * from hospitals; -- DELETE , TRUNCATE -- Difference between DELETE and TRUNCATE --1) DELETE can either delete few records or all records but TRUNCATE ALWAYS REMOVES all data/records/rows. --2) TRUNCATE is much faster than DELETE select * from hospitals; delete from hospitals where hospital_code = 50; truncate table hospitals; drop table hospitals; SQL for Beginners: A Complete Introduction to SQL Basics! https://youtu.be/iZPGAnNZm6U Master SQL Commands: DDL, Data Types & Constraints Explained! https://youtu.be/6if1q_7CGLI Mastering SQL Constraints: Primary Key, Unique Key, Not Null, and CHECK Explained! https://youtu.be/KdGUpf_OTPA Understanding SQL Foreign Keys: Building Relationships Between Tables https://youtu.be/mA_pE0Kg9K4 SQL Identity Column: Auto-Generating Unique Values for Your Tables https://youtu.be/PZVDNekwrNc SQL DML & DDL Commands Explained | Insert, Update, Delete, Truncate, Drop https://youtu.be/DSe2Gw6Z-z0 Master Basic SQL Queries & Operators | Part 1: Fetch, Filter & Count https://youtu.be/HgKW590CVSI SQL Functions and Queries: Aggregate, CAST, REPLACE, ROUND, GETDATE https://youtu.be/w1Vvj4IFYsE Mastering SQL INNER JOIN: Essential Queries & Examples https://youtu.be/NzFpLo1J5oI SQL Group By Explained with Examples | Master Aggregate Queries https://youtu.be/9nrVo0h7Z8o Mastering SQL: Group By, Having, CASE, Order By, Join, Top, and Limit https://youtu.be/sQv2y1CTJIU Introduction to SQL Normalization: 1NF (First Normal Form) - Part 1 https://youtu.be/r_dHyFqK19g Understanding SQL Normalization: 2NF (Second Normal Form) - Part 2 https://youtu.be/2ZF3NVxYIcE Mastering SQL Normalization: 3NF (Third Normal Form) Explained - Part 3 https://youtu.be/ne-0qFcP3ao Master SQL Subqueries: Scalar, Multi-Row, and Correlated Subqueries Explained https://youtu.be/twAnX7-rAAk SQL Tutorial: Remove Duplicate Data Efficiently | Common Interview Question https://youtu.be/M2lwOXk4ZfA SQL Joins Explained: Master INNER, LEFT, RIGHT, FULL, CROSS & SELF Joins with Examples https://youtu.be/0y-u7w7s5ig Master SQL Joins: Self Joins, Outer Joins, and More! https://youtu.be/xfBlQ2x7oSg SQL Queries Using CTE: Profitability & Monthly Sales Differences https://youtu.be/ttKIVVx3JXQ Calculate User Popularity Percentage with SQL CTEs https://youtu.be/_YzwhLdc5z8 SQL Window Functions Explained: ROW_NUMBER, RANK & DENSE_RANK https://youtu.be/wpLNF5hnPxg SQL Window Functions Explained: LEAD & LAG with Real Examples! https://youtu.be/wfubFMAhEds Master SQL Window Functions: FIRST_VALUE, LAST_VALUE, and More! https://youtu.be/FvV0gFIxdA8 Easily Delete Duplicate Rows in SQL Server with ROW_NUMBER() https://youtu.be/p2ZJu3tu91Q Understanding Recursive CTEs in SQL: A Simple Guide https://youtu.be/9H79g5Hv3hE Master SQL PIVOT: Transform Rows into Columns https://youtu.be/iyDJQFY8LAA 🔔 **Subscribe** for more in-depth SQL tutorials and tips! #SQL #SQLTutorial #Database #SQLCommands #LearnSQL #SQLInsert #SQLUpdate #SQLDelete #SQLTruncate #SQLDrop

Download

0 formats

No download links available.

SQL DML & DDL Commands Explained | Insert, Update, Delete, Truncate, Drop | NatokHD