[go: up one dir, main page]

0% found this document useful (0 votes)
8 views2 pages

DDL DML Examples

The document outlines SQL commands for Data Definition Language (DDL) and Data Manipulation Language (DML). DDL commands include creating, altering, truncating, and dropping tables, while DML commands cover selecting, inserting, updating, and deleting records. Additionally, it provides examples for eliminating duplicates and using the WHERE clause in queries.

Uploaded by

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

DDL DML Examples

The document outlines SQL commands for Data Definition Language (DDL) and Data Manipulation Language (DML). DDL commands include creating, altering, truncating, and dropping tables, while DML commands cover selecting, inserting, updating, and deleting records. Additionally, it provides examples for eliminating duplicates and using the WHERE clause in queries.

Uploaded by

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

DDL

1. CREATE TABLE

CREATE TABLE Persons


(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);

Note: For SQL open design of table and for oracle use DESCRIBE command to view
table structure. Example:
DESCRIBE Persons

2. ALTER TABLE

ALTER TABLE Persons


ADD Address2 varchar(255)

ALTER TABLE Persons


DROP COLUMN ADDRESS2

3. TRUNCATE TABLE
TRUNCATE TABLE PERSONS

4. DROP TABLE
DROP TABLE Persons

DML

1. SELECT
SELECT * FROM PERSONS

2. INSERT ROW/ROWS

INSERT INTO Persons (PersonID, LastName, FirstName, Address, City)


VALUES (1, 'Alamdar', 'Rabbia', 'Lhr', 'Lhr');

3. UPDATE
UPDATE PERSONS
SET LastName = 'Alamdar', Address='TEST ADDRESS'
WHERE PersonID = 1;

4. DELETE
DELETE FROM PERSONS
WHERE PersonID = 5;

5. Eliminates Duplicates
SELECT COUNT(DISTINCT Country) FROM Customers;

6. WHERE
SELECT column1, column2, ...
FROM table_name
WHERE condition;

You might also like