0% found this document useful (0 votes)
2 views

dbmdp

The document outlines various SQL Data Definition Language (DDL) and Data Manipulation Language (DML) operations. It includes commands for creating, altering, dropping, and truncating tables, as well as managing indexes. Additionally, it provides examples of DML operations such as inserting, updating, deleting, and selecting records from a table.

Uploaded by

rohitk93639
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

dbmdp

The document outlines various SQL Data Definition Language (DDL) and Data Manipulation Language (DML) operations. It includes commands for creating, altering, dropping, and truncating tables, as well as managing indexes. Additionally, it provides examples of DML operations such as inserting, updating, deleting, and selecting records from a table.

Uploaded by

rohitk93639
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

sql

sql
Copy code
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
BirthDate DATE,
HireDate DATE,
DepartmentID INT
);

2. ALTER TABLE

 Add a new column:

sql
Copy code
ALTER TABLE Employees
ADD Salary DECIMAL(10, 2);

 Modify an existing column:

sql
Copy code
ALTER TABLE Employees
MODIFY COLUMN LastName VARCHAR(100);

 Drop a column:

sql
Copy code
ALTER TABLE Employees
DROP COLUMN BirthDate;

 Rename a column:

sql
Copy code
ALTER TABLE Employees
RENAME COLUMN FirstName TO First_Name;

3. DROP TABLE
sql
Copy code
DROP TABLE IF EXISTS Employees;

4. TRUNCATE TABLE
sql
Copy code
TRUNCATE TABLE Employees;

5. CREATE INDEX
sql
Copy code
CREATE INDEX idx_department
ON Employees (DepartmentID);

6. DROP INDEX
sql
Copy code
DROP INDEX idx_department;

These are the basic DDL operations, including CREATE, ALTER, DROP, TRUNCATE, and INDEX
management, that help define and manage database structures.

4o

You said:

write a query to implement diffrent types of dml statements in SQL.


ChatGPT said:

ChatGPT

Here’s a SQL query template that demonstrates different types of Data Manipulation Language
(DML) operations:

1. INSERT

 Insert a single row:

sql
Copy code
INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate,
DepartmentID, Salary)
VALUES (1, 'John', 'Doe', '2022-01-15', 101, 50000.00);

 Insert multiple rows:

sql
Copy code
INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate,
DepartmentID, Salary)
VALUES
(2, 'Jane', 'Smith', '2023-03-20', 102, 55000.00),
(3, 'Mark', 'Johnson', '2021-11-02', 103, 60000.00);

2. UPDATE

 Update a single record:

sql
Copy code
UPDATE Employees
SET Salary = 65000.00
WHERE EmployeeID = 1;

 Update multiple records:

sql
Copy code
UPDATE Employees
SET DepartmentID = 104
WHERE DepartmentID = 101;

3. DELETE

 Delete a single record:

sql
Copy code
DELETE FROM Employees
WHERE EmployeeID = 2;

 Delete multiple records:

sql
Copy code
DELETE FROM Employees
WHERE DepartmentID = 104;

4. SELECT

 Select all records from a table:

sql
Copy code
SELECT * FROM Employees;

 Select specific columns:

sql
Copy code
SELECT FirstName, LastName, Salary
FROM Employees;
 Select records with a condition:

sql
Copy code
SELECT EmployeeID, FirstName, LastName
FROM Employees
WHERE Salary > 50000;

You might also like