KEMBAR78
DDL or Data Definition Language | PDF | Databases | Information Retrieval
0% found this document useful (0 votes)
86 views3 pages

DDL or Data Definition Language

DDL commands are used to define and modify the structure of database objects like tables and indexes, but not the data itself. Common DDL commands include CREATE, ALTER, DROP, TRUNCATE, and COMMENT. DML commands like INSERT, UPDATE, and DELETE are used to manipulate the data within database tables. SELECT is the main SQL statement for querying and viewing data. Examples show how to create a database and table, insert data, and perform basic queries using SELECT with clauses like WHERE, GROUP BY, and ORDER BY.

Uploaded by

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

DDL or Data Definition Language

DDL commands are used to define and modify the structure of database objects like tables and indexes, but not the data itself. Common DDL commands include CREATE, ALTER, DROP, TRUNCATE, and COMMENT. DML commands like INSERT, UPDATE, and DELETE are used to manipulate the data within database tables. SELECT is the main SQL statement for querying and viewing data. Examples show how to create a database and table, insert data, and perform basic queries using SELECT with clauses like WHERE, GROUP BY, and ORDER BY.

Uploaded by

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

DDL or Data Definition Language actually consists of the SQL commands that can be used to define

the database schema. It simply deals with descriptions of the database schema and is used to create and
modify the structure of database objects in the database. DDL is a set of SQL commands used to create,
modify, and delete database structures but not data. These commands are normally not used by a general
user, who should be accessing the database via an application. List of DDL commands:
• CREATE: This command is used to create the database or its objects (like table, index, function, views,
store procedure, and triggers).
• DROP: This command is used to delete objects from the database.
• ALTER: This is used to alter the structure of the database.
• TRUNCATE: This is used to remove all records from a table, including all spaces allocated for the records
are removed.
• COMMENT: This is used to add comments to the data dictionary.
• RENAME: This is used to rename an object existing in the database.

DML(Data Manipulation Language)


The SQL commands that deal with the manipulation of data present in the database belong to DML or Data
Manipulation Language and this includes most of the SQL statements. It is the component of the SQL
statement that controls access to data and to the database. Basically, DCL statements are grouped with DML
statements.
List of DML commands:
• INSERT: It is used to insert data into a table.
• UPDATE: It is used to update existing data within a table.
• DELETE: It is used to delete records from a database table.

SQL | SELECT Query

CREATE DATABASE:
CREATE DATABASE Customer;

CREATE TABLE:
CREATE TABLE Customer(
CustomerID INT PRIMARY KEY,
CustomerName VARCHAR(50),
LastName VARCHAR(50),
Country VARCHAR(50),
Age int(2),
Phone int(10)

);
INSERT VALUES:
INSERT INTO Customer (CustomerID, CustomerName, LastName, Country, Age, Phone)
VALUES (1, 'Shubham', 'Thakur', 'India','23','xxxxxxxxxx'),
(2, 'Aman ', 'Chopra', 'Australia','21','xxxxxxxxxx'),
(3, 'Naveen', 'Tulasi', 'Sri lanka','24','xxxxxxxxxx'),
(4, 'Aditya', 'Arpan', 'Austria','21','xxxxxxxxxx'),
(5, 'Nishant. Salchichas S.A.', 'Jain', 'Spain','22','xxxxxxxxxx');

SELECT Statement:

SELECT * FROM table_name;


— asterisks represent all attributes of the table

Query to fetch the fields CustomerName, LastName from the table Customer:
SELECT CustomerName, LastName FROM Customer;

SELECT Statement with WHERE Clause:

SELECT CustomerName FROM Customer where Age = '21';

SQL SELECT Statement with GROUP BY Clause:

SELECT COUNT (item), Customer_id FROM Orders GROUP BY order_id;

SELECT Statement with HAVING Clause:

SELECT Department, sum(Salary) as Salary


FROM employee
GROUP BY department
HAVING SUM(Salary) >= 50000;

SELECT Statement with ORDER BY clause in SQL:


SELECT * FROM Customer ORDER BY Age DESC;

UPDATE
UPDATE Customer SET Country= ‘SriLanka’ WHERE Country= ‘Sri lanka’;

DELETE

DELETE FROM Customer WHERE CustomerID=5;

VIEW
CREATE VIEW Details AS
SELECT CustomerName, Country
FROM Customer
WHERE CustomerID < 3;

You might also like