Dr. Shubhra Goyal Facilitator DDL commands Session 2 MySQL
Holistic focus on the individual (SQ, EQ, IQ, and PQ) Interrelationships are dynamic between individual, team, institution and the external environment (systemic) Strategy affects individual, team, organisational, and environmental performance Delivery requires alignment of strategy, structure, systems and culture REGENESYS INTEGRATED LEADERSHIP AND MANAGEMENT MODEL
REGENESYS GRADUATE ATTRIBUTES
Introduction to SQL
What is SQL? SQL (Structured Query Language) is a standard programming language used to manage and manipulate relational databases. It is used to query, insert, update, and delete data, as well as manage database structures.
Why is SQL Needed? - To store and retrieve data efficiently - To interact with relational databases - To enforce data integrity and consistency - To support transaction processing - To simplify complex data manipulation with minimal code
Benefits of SQL - Easy to learn and use - High performance for data operations - Standardized language across systems - Secure access to data - Enables data analysis and reporting
Significance of SQL - Forms the backbone of modern data storage systems - Essential for data-driven decision making - Used in various domains like finance, healthcare, education - Supports integration with programming languages and analytics tools
Types of SQL Commands SQL commands are categorized into: 1. Data Definition Language (DDL) 2. Data Manipulation Language (DML) 3. Data Control Language (DCL) 4. Transaction Control Language (TCL) 5. Data Query Language (DQL)
Data Definition Language commands 1. CREATE Purpose: Used to create new database objects such as tables, views, indexes, schemas, or databases. CREATE TABLE Employees ( EmpID INT PRIMARY KEY, Name VARCHAR(100), Position VARCHAR(50), Salary DECIMAL(10, 2) );
Data Definition Language commands 2. ALTER Purpose: Used to modify an existing object (like adding, removing, or modifying columns). Syntax (Add Column): ALTER TABLE table_name ADD column_name datatype; MODIFY COLUMN ALTER TABLE table_name MODIFY column_name new_datatype ;
Data Definition Language commands 2. ALTER Purpose: Used to modify an existing object (like adding, removing, or modifying columns). Syntax ( drop Column): ALTER TABLE table_name DROP COLUMN column_name ;
Summary of DDL commands Command Purpose Affects Data Rollback Possible Example CREATE Creates a new object ❌ ❌ CREATE TABLE ... ALTER Modifies an existing object ❌ ❌ ALTER TABLE ... ADD ... DROP Deletes an object permanently ✅ ❌ DROP TABLE Employees; TRUNCATE Deletes all rows in a table ✅ (no rows) ❌ TRUNCATE TABLE Employees; RENAME Changes the name of a table/column ❌ ❌ RENAME TABLE Employees TO Staff;
Quiz Questions Which of the following is NOT a DDL command? A. CREATE B. DROP C. INSERT D. ALTER
Answer: C. INSERT
What does the TRUNCATE command do in SQL? A. Deletes the table structure B. Removes all rows but retains the table C. Modifies existing rows D. Renames a table