0% found this document useful (0 votes)
87 views15 pages

DBMS Presentation Vedika and Pratiksha

DDL commands are used to modify or alter the structure of a database. The main DDL commands are CREATE, ALTER, DROP, TRUNCATE, which are used to create, modify, or delete database objects like tables. DML commands like SELECT, INSERT, UPDATE, DELETE manipulate and manage the data within database tables. DCL commands like GRANT and REVOKE are used to control access privileges for users.

Uploaded by

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

DBMS Presentation Vedika and Pratiksha

DDL commands are used to modify or alter the structure of a database. The main DDL commands are CREATE, ALTER, DROP, TRUNCATE, which are used to create, modify, or delete database objects like tables. DML commands like SELECT, INSERT, UPDATE, DELETE manipulate and manage the data within database tables. DCL commands like GRANT and REVOKE are used to control access privileges for users.

Uploaded by

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

DDL Commands

DDL commands are SQL commands used to


modify or alter the structure of the database. The
following is the list of DDL commands in SQL:
The CREATE command creates database objects,
tables, and triggers.
ALTER command alters the database structure by
adding, deleting, and modifying columns of the
already existing tables, like renaming and changing
the data type and size of the columns.
he DROP command deletes the defined table with
all the table data, associated indexes, constraints,
triggers, and permission specifications.
Alter command

Syntax:
ALTER TABLE table_name ADD(column_name data type);

Examlpe:
TER TABLE table stud ADD(address varchar(100));The
Create Commad
After installing Database management system like sql server,
oracle on computer, we need to manage database and for
create a new database we use CREATE command.

Syntax:

CREATE TABLE tablename(columns 1 datatype,


Columns 2 datatype,column 3 datatype)

Example:
CREATE TABLE Student
(ID int NOTNULL,
Name varchar(50) NOTNULL,
City varchar(50) NULL,
Email varchar(100) NULL);
Drop command:
DROP is used to delete a whole database or just a table.
In this article, we will be learning about the DROP statement
which destroys objects like an existing database, table, index,
or view. A DROP statement in SQL removes a component from
a a relational database management systen(RDBMS).

Syntax:
DROP TABLE table_name;

Example:
DROP TABLE student_details;
Truncate:

The TRUNCATE command is used to remove all of the rows from a table,
regardless of whether or not any conditions are met and resets the table definition.
It is a DDL(Data Definition Language) command. It is also a DDL(Data Definition
Language) command.
Syntax:
TRUNCATE TABLE table_name;

Example:
CREATE TABLE CUSTOMER(ID INT NOT
NULL,
NAME VARCHAR(28) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25),
SALARY DECIMAL(13,2),
PRIMARY KEY(ID));
DML COMMAND:
SELECT is the most important data manipulation command in
Structured Query Language. The SELECT command shows the
records of the specified table. It also shows the particular record of a
particular column by using the WHERE clause.

SELECT command:

Syntax:
SELECT column1, column2,….
FROM table_name;

Example:
SELECT CustomerName, City FROM Customer
INSERT command:
The SQL INSERT INTO Statement is used to add new rows of
data into a table in the database. Almost all the RDBMS
provide this SQL query to add the records in database tables.

Syntax:
INSERT INTO
table_name(column1 ,column2 ,column3,.)
Values(value1,value2,value3,..)

Example:
INSERT INTO
table_name(column1 ,column2 ,column3,.)
VALUES(value1,value2,value3,..)
Update command:
An UPDATE query is used to change an existing row or rows
in the database. UPDATE queries can change all tables’ rows,
or we can limit the update statement affects for certain rows
with the help of the WHERE clause.

Syntax :
UPDATE table_name
SET Column1 = value1,column2=value2,….WHERE
condition;

Example:
UPDATE Customers
SET CustomerName=’Alfred Schmitd’,City=’Frankfurt’
WHERE Customer=1;
DELET E command:

The Delete command in SQL is a part of the Data Manipulation


Language, a sub-language of SQL that allows modification of data
in databases. This command is used to delete existing records from
a table. Using this, you can either delete specific records based on a
condition or all the records from a table.

Syntax:
DELETE FROM table_name WHERE condition;

Example:
DELETE FROM customers;
DCL command:
DCL commands are used for access control and permission
management for users in the database. With them we can easily
allow or deny some actions for users on the tables or records
(row level security). DCL commands are: GRANT.

Grant command:
Syntax:
GRANT privilegeName on objectName
To {username | public | roleName}

Example:
GRANT SELECT ON employee TO user1;This
Command grants a SELECT permission on
Employee table to user1.
REVOKE comman:
The REVOKE command in SQL is used to revoke or withdraw
permissions that were previously granted to an account on a
database object
Syntax:
REVOKE privilege [,…]
ON DataBase_OBJECT[,….]
FROM ROLE [CASECAD | RESTRICT]

Example:
REVOKE SELECT ON employee FROM user1;This
command will REVOKE a SELECT privilege on
employee table from user1.:
COMMIT command:

The COMMIT command is an essential part of SQL for saving


database changes. It's executed after a DML (Data
Manipulation Language) statement, such
as INSERT, DELETE, or UPDATE, to ensure permanent
changes.
Syntax:
Commit;

Example:
DELETE from customer where state=Texes;
COMMIT;
ROLLBACK command:

ROLLBACK is a transactional control language in SQL. It


lets a user undo those transactions that aren't saved yet in the
database. One can make use of this command if they wish to
undo any changes or alterations since the execution of the
last COMMIT.

Syntax:
ROLLBACK TO SAVEPOINT_NAME;

Example:
ROLLBACK TO SAVEPOINT_STUDENT;
CONCLUSION:.

Data Definition Language (DDL) statements are used to


define the database structure or schema. Data Definition
Language describes how the data should exist in the
database. Therefore, language statements like CREATE
TABLE or ALTER TABLE belong to the DDL. DDL is
about "metadata".

You might also like