Aim DBMS2023 V

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

EXP.NO.

1 DATA DEFINITION LANGUAGE(DDL),


DATA MANIPULATION LANGUAGE(DML),
TRANSACTION CONTROL LANGUAGE(TCL),
DATA CONTROL LANGUAGE(DCL) COMMANDS

AIM:
To write SQL commands to implement Data Definition Language(DDL),Data Manipulation
Language(DML),Transaction Control Language(TCL),Data control languages(DCL) in Oracle.

COMMANDS DESCRIPTION

SQL(STRUCTURED QUERY LANGUAGE.):


- SQL is a widely used Query language designed to interface with databases
- SQL commands are instructions. It is used to communicate with the database.
- It is also used to perform specific tasks, functions, and queries of data.
- SQL can perform various tasks like create a table, add data to tables, drop the table, modify
the table, set permission for users.

1)DATADEFINITIONLANGUAGE (DDL)DESCRIPTION:
- It is used to communicate with database.DDL defines the table structure in database.
- DDL is used to: Create an object, Alter the structure of an object , To drop the object created.
OVERVIEW:
1.CREATE - to create objects in the database
2.ALTER - alters the structure of the objects in the database DROP - delete objects from the
database
3.TRUNCATE - remove all records from a table, including all spaces allocated for the records
are removed
4.RENAME- change the table name and column name
5.DROP- Drop the database objects.
COMMENT - add comments to the data dictionary

//CREATE TABLE
It is used to create a table in SQL.
Syntax: Create table <tablename> (column_name1 data_ type constraints,column_name2
data_ type constraints …)
Example :
create table customer(cust_name varchar2(15),social_security_no number(11),cust_street
varchar2(7),cust_city varchar2(10));

//ALTER TABLE
Alter command is used to:
1. Add a new column.
3. Modify the existing column definition.
3. To include or drop integrity constraint.
Syntax: alter table <tablename> add/modify (attribute datatype(size));
Example:
1. Alter table emp add (phone_no char (20));
2. Alter table emp modify(phone_no number (10));
3. ALTER TABLE EMP ADD CONSTRAINT Pkey1 PRIMARY KEY (EmpNo);

//DROP TABLE
It will delete the table in database.
Syntax : drop table <tableame>
Example: drop table prog20; Here prog20 is table name

//TRUNCATE TABLE
If there is no further use of records stored in a table and the structure has to be retained then
the records alone can be deleted.
Syntax: TRUNCATE TABLE <TABLE NAME>;
Example: Truncate table customer;

//DESCRIPTION
This is used to view the structure of the table.
Syntax : desc <tablename>
Example: desc emp;

//RENAMING THE TABLES


Rename command is used to change the original table name.
Syntax: Rename <oldtable> to <new table>;
Example: rename emp to emp1;

2)DATA MANIPULATION LANGUAGE (DML-INSERT, DELETE, UPDATE)


- Data Manipulation Language (DML) is used by computer programs or database users to
retrieve, insert,delete and update data in a database.
- Currently, the most popular data manipulation language is that of SQL,which is used to
retrieve and manipulate data in a Relational database.

//DML Commands
1.INSERT – This is used to add one or more rows to a table.
The values are separated by commas and the data types char and date are enclosed in
apostrophes.
The values must be entered in the same order as they are defined.

Syntax 1 : insert into <table name> values (List of Data Values)


Syntax 2 : insert into <table name> (column names) values (list of data values) Insert command
using User interaction
Syntax 3: insert into <Table name> values (&columnname1,&columnname2…)

Example: Insert into stud values(&reg, ‘&name’, &percentage);


Example: insert into s values(‘s3’,’sup3’,’blore’,10)
2.SELECT – is used to retrieve information from the table.it is generally refered to as querying
the table. We can either display all columns in a table or only specify column from the table.

Syntax 1: select * from <table name>;


Syntax 2: select columnname1,columnname 2 from <table name>; Syntax 3: select * from
<table name> where <condition>;

Example :
a)Find the names of all branches in the loan table
SQL> select branch_name from loan;
b)List all account numbers made by brighton branch
SQL> select acc_no from account where branch_name = 'brighton';
c)List the customers who are living in the city harrison
SQL> select cust_name from customer where cust_city = 'harrison';

//other formats of select command


//The retrieval of specific columns from a table:
Syntax: Select column_name1, …..,column_name from <table name>;
: Select empno, empname from emp;

//Elimination of duplicates from the select clause:


It prevents Example retrieving the duplicated values .Distinct keyword is to be used.
Syntax: Select DISTINCT col1, col2 from <table name>;
Example: Select DISTINCT job from emp;

//Select command with where clause:


To select specific rows from a table we include ‘where’ clause in the select command.
It can appear only after the ‘from’ clause.
Syntax: Select column_name1,column_name from <tablename> [where
<condition/expression>];
Example: Select empno, empname from emp where sal>4000;

//Select command with order by clause:


Syntax: Select column_name1, …..,column_name from <tablename> where condition order
by colmnname;
Example: Select empno, empname from emp order by empno;

//Select command to create a table:


Syntax: create table tablename as select * from existing_<tablename>;
Example: create table emp1 as select * from emp;

//Select command to insert records:


Syntax: insert into <tablename>( select columns from existing_tablename);
Example: insert into emp1 ( select * from emp);
3.UPDATE COMMAND
It is used to alter the column values in a table.
A single column may be updated or more than one column could be updated.

Syntax:update <tablename>set field=values [where <condition/expression>];


Example:Update emp set sal = 10000 where empno=135;

4.DELETE COMMAND
After inserting row in a table we can also delete them if required.
The delete command consists of a from clause followed by an optional where clause.

Syntax: Delete from <tablename> [where <condition/expression>];


Example:delete from emp where empno=135;

3)TRANSACTION CONTROL LANGUAGE(TCL) COMMANDS:

COMMANDS OVERVIEW
COMMIT - save work done & it is visible to other users.
SAVEPOINT - identify a point in a transaction to which you can later roll back.
ROLLBACK - restore database to original since the last COMMIT
SET TRANSACTION - Change transaction options like what rollback segment to use

SAVEPOINT
Syntax: savepoint username;
SQL> savepoint emp; savepoint created;

COMMIT
Syntax: commit;
SQL> commit; Output:
Commit complete.

ROLLBACK
Syntax:rollback to savepoint_text_identifier;
SQL> rollback to emp;
Output:Rollback complete.

4)DATA CONTROLLING LANGUAGE (DCL) COMMANDS


DCL helps users to retrieve and modify the data stored in the database with some specified
queries.
Grant and Revoke belong to these types of commands of the Data controlling Language.
DCL is a component of SQL commands.
1.GRANT :
SQL Grant command is specifically used to provide privileges to database objects for a user.
This command also allows users to grant permissions to other users too.
Syntax: grant privilege_name on object_name to {user_name | public | role_name}
Here privilege_name is which permission has to be granted, object_name is the name of the
database object, user_name is the user to which access should be provided, the public is used
to permit access to all the users.

Syntax: revoke privilege_name on object_name from {user_name | public | role_name}


Example: grant insert, select on accounts to Ram

By the above command user ram has granted permissions on accounts database object like he
can query or insert into accounts.

2.REVOKE :
Revoke command withdraw user privileges on database objects if any granted.
It does operations opposite to the Grant command.
When a privilege is revoked from a particular user U, then the privileges granted to all other
users by user U will be revoked.
Example: revoke insert,select on accounts from Ram
By the above command user ram’s permissions like query or insert on accounts database object
has been removed.

Result.
Thus the DDL.DML,TCL,DCL commands are executed and verified successfully.
EX.NO2 INTEGRITY CONSTRAINTS

Aim:
To write SQL query to implement the different types of Integrity Constraints.

COMMANDS DESCRIPTION
INTEGRITY CONSTRAINTS
- SQL Constraints are rules used to limit the type of data that can go into a table, to maintain the
accuracy and integrity of the data inside table.
- Integrity constraints are pre-defined set of rules that are applied on the table fields(columns) or
relations to ensure that the overall validity, integrity and consistency of the data present in the database
table is maintained.
- Integrity constraints are a set of rules. It is used to maintain the quality of information.

TYPES OF INTEGRITY CONSTRAINTS

1. DOMAIN INTEGRITY
Domain constraints can be defined as the definition of a valid set of values for an attribute.
a) NOT NULL – It will not allow null values.
NOT NULL constraint restricts a column from having a NULL value.
Once NOT NULL constraint is applied to a column, you cannot pass a null value to that column.
Syntax : create table <table name>(columnname datatype(size)constraint constraint_name not null);
Example : CREATE table Student(s_id number NOT NULL,Name varchar(60),Age number)

b) CHECK - Use the CHECK constraint when you need to enforce integrity rules that can be
evaluated based on a condition (logical expression).
CHECK constraint is used to restrict the value of a column between a range.
It performs check on the values,before storing them into the database.
Its like condition checking before saving data into a column
Syntax : create table <table name>(columnname data type(size) constraint constraint_name
check(check_condition));
Example : create table Student(s_id number NOT NULL
CHECK(s_id>0),Name varchar(60)NOT NULL,Age number);

2. ENTITY INTEGRITY :
The entity integrity constraint states that primary key value can't be null.
a) UNIQUE
– Avoid duplicate values. A UNIQUE constraint field will not have duplicate data.
Syntax : create table <table name>(columnname data type (size) constraint constraint_name unique);
Example : CREATE table Student(s_id number NOT NULL UNIQUE, Name varchar(60), Age
number);

b) Composite UNIQUE – Multicolumn unique key is called composite unique key


Syntax : create table <table name>(columnname1 data type (size), columnname2 data type (size),
constraint constraint_name unique (columnname1, columnname2));
c) PRIMARY KEY –Primary key constraint uniquely identifies each record in a database. It will
not allow null values and avoid duplicate values.
Syntax : create table <table name>(columnname data type (size) constraint constraint_name primary
key);
Example : CREATE table Student (s_id number PRIMARY KEY, Name varchar(60) NOT NULL,
Age int);

d) Composite PRIMARY KEY – Multicolumn primary key is called composite primary key
Syntax : create table <table name>(columnname1 datatype(size),
columnname2 datatype(size),constraintconstraint_name primary
key(columnname1,columnname2));

3. REFERENTIAL INTEGRITY
Reference key (foreign key):
- Its represent relationships between tables.Foreign key is a column whose values are derived from the
primary key of the same or some other table.
- FOREIGN KEY is used to relate two tables.
- FOREIGN KEY constraint is also used to restrict actions that would destroy links between tables.
- A referential integrity constraint is specified between two tables.
- In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of
Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2.

Syntax : create table <table name>(columnname data type (size) constraint constraint_name
references parent_table_name);
Example : CREATE table Order_Detail(order_id number PRIMARY KEY,order_name varchar(60)
NOT NULL, c_id number FOREIGN KEY REFERENCES Customer_Detail(c_id));

To view the Constraints


Example: select *from user_constraints where table_name =”TABLE NAME”;

Adding keys for an existing table


Syntax: Alter table <table name >add constraint <constraint name>primary key (column
name);

Dropping the keys


Syntax: Alter table <table name>drop constraint <constraint name>;

Result.
Thus the Different types Integrity Constraints are executed and verified successfully.
EX.NO3 WHERE CLAUSE CONDITION AND AGGREGATE
FUNCTIONS

Aim:
To Write different SQL queries using Where conditions and Aggregate Functions.

WHERE CLAUSE DESCRIPTION:

Where Clause Uses:


The WHERE clause is used to filter records. It is used to extract only those records that
fulfill a specified condition

WHERE clause Syntax:


SELECT column1, column2, ... FROM table_name WHERE condition;
Example: SELECT * FROM Customers WHERE Country='Mexico';

While the SELECT clause specifies the columns to be returned from the table(s),
the WHERE clause contains the conditions that must evaluate to true for a row to be returned
as a result.

The WHERE clause is not only used in SELECT statements, it is also used
in UPDATE, DELETE, etc.!

SPECIAL OPERATORS :
In / not in – used to select a equi from a specific set of values.
Any - used to compare with a specific set of values.
Between /not between – used to find between the ranges.
%Like / not like – used to do the pattern matching.

ARITHMETIC OPERATIONS
- Various operations such as addition, multiplication, subtraction and division can be
performed using the numbers available in the table.

DISTINCT
- This keyword is used along with select keyword to display unique values from the specified
column.
- It avoids duplicates during display.
Example: SQL> select DISTINCT lastname from person

ORDER BY CLAUSE
The order by clause arranges the contents of the table in ascending order (by default)
or in descending order (if specified explicitly) according to the specified column.
Example :
SQL> select pid, firstname,age from person order by age;
CONCATENATION OPERATOR(||)
- This combines information from two or more columns in a sentence according to the
format specified.

LOGICAL OPERATORS
AND : The oracle engine will process all rows in a table and displays the result only
when all of the conditions specified using the AND operator are specified.
OR : The oracle engine will process all rows in a table and displays the result only when
any of the conditions specified using the OR operators are satisfied.
NOT : The oracle engine will process all rows in a table and displays the result only
when none of the conditions specified using the NOT operator are specified.
BETWEEN : In order to select data that is within a range of values, the between
operator is used. (AND should be included)

AGGREGATE FUNCTIONS(RETURNS SINGLE OUTPUT)


- An aggregate function performs a calculation on a set of values, and returns a single
value as output.
A AGGREGATE FUNCTIONS returns a result based on group of rows.
1.avg - The AVG() function returns the average value of a numeric column.
Example: select avg (total) from student;
2.max - The MAX() function returns the largest value of the selected column.
Example: select max (percentagel) from student;
3.min -The MIN() function returns the smallest value of the selected column.
Example: select min (marksl) from student;
4.sum - The SUM() function returns the total sum of a numeric column.
Example: select sum(price) from product;
5.count - The COUNT() function returns the number of rows that matches a specified criterion.
Example: select count(price) from product;

GROUP BY CLAUSE
The GROUP BY statement groups rows that have the same values into summary
rows,like "find the number of customers in each country".
Example: Select max(percentage), deptname from student group by deptname;

HAVING CLAUSE
This is used to specify conditions on rows retrieved by using group by clause.
Example: Select max(percentage), deptname from student group by deptname having
count(*)>=50;

Result.
Thus the Where clause usage and Aggregate functions are executed and verified
successfully.
EX.NO4 : SUB QUERY AND SIMPLE JOIN OPERATIONS
Aim.
To execute and verify the r nested queries ,Sub queries ,different types of Joins.

1) SUBQUERY COMMANDS DESCRIPTION


SUB QUERIES:
- The query within another is known as a sub query.
- A statement containing sub query is called parent statement.
- The rows returned by sub query are used by the parent statement.
- A subquery is a query within a query.
- In Oracle, you can create subqueries within your SQL statements.These subqueries can reside
in the WHERE clause,the FROM clause, or the SELECT clause.

Example. SELECT SPLACE, PNAME FROM STUDY WHERE PNAME = (SELECT


PNAME FROM SOFTWARE WHERE SCOST = (SELECT MAX (SCOST) FROM
SOFTWARE);

NESTED QUERIES :
Nesting of queries one within another is known as a nested queries.

2)JOINS:
- Join is a query in which data is returned from two or more tables.
- A JOIN clause is used to combine rows from two or more tables, based on a related
column between them.
- Types of Joins
1.Equi Join 2. Inner Join 3.Left Outer Join 4.Right Outer Join 5.Full join

How the join will be performed:


Step 1: Make the Cartesian product of the given tables.
Step 2: Check for the equality on common attributes for the given tables.
Natural join/Equi Join:
It returns the matching rows from the table that are being joined.
Syntax: select <attribute> from TN where TN1.attribute=TN2.attribute.

Inner join(simple join):


It returns the matching rows from the table that are being joined.
Syntax: select <attribute> from TN1 innerjoin TN2 on TN1.attribute=TN2.attribute.

Left outer join:


It returns all the rows from the table1 even when they are unmatched.
Syntax:
1.select <attribute> from TN1 left outer join TN2 on TN1.attribute=TN2.attribute.
2.select <attribute> from TN where TN1.attribute(+)=TN2.attribute.

Right outer join:


It returns all the rows from the table2 even when they are unmatched.
Syntax:
1. select <attribute> from TN1 right outer join TN2 on TN1.attribute=TN2.attribute.
2. select <attribute> from TN where TN1.attribute=(+)TN2.attribute.

Full outer join:


It is the combination of both left outer and right outer join.
Syntax: select <attribute> from TN1 full join TN2 on TN1.attribute=TN2.attribute.

Result:
Thus the SQL commands for Sub queries ,Joins are executed and verified
successfully.
EX.NO 5 TRIGGERS
Aim:
To write PL/SQL programs to implement the concept of Triggers in Oracle.

Commands Description
Triggers:
- Triggers are defined as stored programs which are automatically executed
whenever some events such as CREATE, ALTER, UPDATE, INSERT, DELETE
takes place.
- A trigger is a statement that is executed automatically by the system as a side
effect of a modification to the database.
- They can be defined on a database, table, view with which event is associated.

The parts of a trigger:


- Trigger statement:
Specifies the DML statements and fires the trigger body. It also specifies the
table to which the trigger is associated.
- Trigger body or trigger action:
It is a PL/SQL block that is executed when the triggering statement is used.
- Trigger restriction:
Restrictions on the trigger can be achieved

The different uses of triggers are as follows,


- To generate data automatically
- To enforce complex integrity constraints
- To customize complex securing authorizations
- To maintain the replicate table
- To audit data modifications

Types Of Triggers
1.Row Level Trigger –
- Row level triggers execute once for each and every row in the transaction.
Example: If 1500 rows are to be inserted into a table, the row level trigger would execute
1500 times.

2.Statement Level Trigger -


- This is the default trigger that is invoked Statement level triggers executes only once
for each single transaction.
Example: If 1500 rows are to be inserted into a table, the statement level trigger would
execute only once

The trigger events:


Before: It fires the trigger before executing the trigger statement.
After: It fires the trigger after executing the trigger statement.
Variables Used In Triggers
1.old 2.new
These two variables retain the new and old values of the column updated in the database.
The values in these variables can be used in the database triggers for data manipulation.

Trigger syntax:
CREATE [OR REPLACE] TRIGGER <trigger_name>
{ BEFORE|AFTER } { INSERT|DELETE|UPDATE } ON <table_name>
[ REFERENCING [ NEW AS <new_row_name> ] [OLD AS <old_row_name> ] ]
[ FOR EACH ROW [ WHEN ( <trigger_condition> ) ] ]
<trigger_body>

Result:

Thus the PL/SQL program for triggers are created, executed successfully.
EX.NO 6 VIEWS AND INDEX

Aim:
To write PL/SQL program to implement views and index.

VIEW
- A View in SQL is simply a virtual table created based on a result set of another SQL
statement.
- Views were introduced to reduce the complexity of multiple tables and deliver data in a simple
manner.
- Views help us maintain data integrity and provide security to the data, thus acting as a
security mechanism.
- Views hide the complexity of the data in the database.
- Views provide security to the data, acting as a security mechanism.
- Being a virtual table, views take very little storage since the database contains only a view's
statements (definition) and not a copy of all the tables the view is creating.

Sql Creating A View


Syntax:
CREATE VIEW view_name AS SELECT column1, column2...column N
FROM table1, table2...table N WHERE condition;
To see the data in the view:
SELECT * FROM [view_name];

UPDATING A VIEW
You can update a view by using the following syntax:
Syntax : update viewname set columnname =< value> where columnname=<value>

INSERT DATA INTO VIEW.


Syntax : insert into viewname values (view column values);

DELETE DATA FROM VIEW


Syntax : delete from VIEWNAME where COLUMNNAME=VALUES;

DROPPING A VIEW:
You can delete a view with the DROP VIEW command.
Syntax : DROP VIEW view_name
INDEX:
- Indexes are special lookup tables, that the database search engine can use to speed up
data retrieval.
- A SQL index is used to retrieve data from a database very fast.
- Simply put, an index is a pointer to data in a table.
- An index helps to speed up SELECT queries and WHERE clauses.
- indexes are intended to enhance a database's performance.
- Indexes should not be used on small tables.

CREATE SIMPLE INDEX:


- Create index command is used for generating the table index in SQL.
- Just one table column is used to construct a one-way-column index.
SYNTAX: CREATE INDEX index_name ON table_name (column_name);

COMPOSITE INDEXES :
- A composite index is an index on two or more columns of a table.
SYNTAX: CREATE INDEX index_name on table_name (column1, column2);

DROP INDEX:
SYNTAX: DROP INDEX index_name;

Result:
Thus the concept of index and views are created and successfully executed in oracle.
EX.NO7 FUNCTIONS AND STORED PROCEDURES

Aim:
To write PL/SQL programs that execute the concept of procedures and functions in Oracle.

Procedure Description

➢ A procedure is a set of instructions which takes input and performs a certain task.
➢ In SQL, procedures do not return a value.
➢ In SQL, a procedure is basically a precompiled statement which is stored inside the
database. Therefore, a procedure is sometimes also called a stored procedure.
➢ A procedure always has a name, list of parameters, and compiled SQL statements.
➢ In SQL, a procedure does not return any value.
➢ The procedures cannot be called from function.
➢ A procedure can be used to read and modify data.
➢ It cannot be called in a query.
➢ In a procedure, DML statements can be used.

SYNTAX:

CREATE or REPLACE PROCEDURE name(parameters)


IS
variables;
BEGIN
//statements;
END;

Function Description
➢ In SQL, a function returns a value.
➢ In other words, a function is a tool in SQL that is used to calculate anything to produce
an output for the provided inputs.
➢ Each and every time functions are compiled(Not precompiled) they provide output
according to the given input.
➢ In SQL queries, when a function is called, it returns the resulting value.
➢ It also controls to the calling function.
➢ However, in a function, we cannot use some DML statements like Insert, Delete,
Update, etc.
➢ Also, a function can be called through a procedure.
➢ Based on definition, there are two types of functions namely, predefined function and
user defined function.
➢ Another important point about functions is that they may or may not return a value,
➢ i.e. a function can return a null valued as well.
➢ The function can be called using Stored Procedure.
➢ A function used only to read data.
➢ It can be called in a query.
➢ DML statements such as (Insert, Delete, and Update) cannot be used in a function.
SYNTAX:
CREATE [OR REPLACE ] FUNCTION function_name
[ (parameter_name type [, …] ) ]

// this statement is must for functions


RETURN return_datatype
{ IS | AS }

BEGIN
// program code

[EXCEPTION
exception_section;

END [function_name];

Parameter:
The parameter is variable or placeholder of any valid PL/SQL datatype through which
the PL/SQL subprogram exchange the values with the main code.

This parameter allows to give input to the subprograms and to extract from these subprograms.

Types:
➢ IN Parameter
➢ OUT Parameter
➢ IN OUT Parameter

IN Parameter:
➢ This parameter is used for giving input to the subprograms.
➢ It is a read-only variable inside the subprograms.

OUT Parameter:
➢ This parameter is used for getting output from the subprograms.
➢ It is a read-write variable inside the subprograms. Their values can be changed inside
the subprograms.

IN OUT Parameter:
➢ This parameter is used for both giving input and for getting output from the
subprograms.
➢ It is a read-write variable inside the subprograms. Their values can be changed inside
the subprograms.
➢ In the calling statement, these parameters should always be a variable to hold the value
from the subprograms.
RETURN
➢ RETURN is the keyword that instructs the compiler to switch the control from the
subprogram to the calling statement.
➢ In subprogram RETURN simply means that the control needs to exit from the
subprogram.
➢ Once the controller finds RETURN keyword in the subprogram, the code after this will
be skipped.

Result:
Thus the PL/SQL Procedure and Functions were created and executed verified
successfully.
EX.NO 8 DOCUMENT BASED DB CREATION USING MONGODB

Aim:
To create document based database using MONGODB.

CRUD(CREATE,READ,UPDATE,DELTE) OPERATIONS IN MONGODB


1. Create Operations in MongoDB
MongoDB Create Operations are used to create a new Document in a Collection. In case the
Collection is not present then it creates the Collection as well.

The below two methods are used for MongoDB Create Operations.

• db.collection_name.insertOne()
• db.collection_name.insertMany()

In the following example, we can see the Collection "users_detail" is created with the below
data.

2.Read Operations in MongoDB


MongoDB Read Operations are used to read the Documents from the Collection.

MongoDB provides the following method to perform the Read Operations.

• db.collection_name.find()

The following is an example of Read Operations in MongoDB.


3. Update Operations in MongoDB
MongoDB Update Operations are used to modify existing Documents in the Collection.

The following methods are used to perform the Update Operations in MongoDB.

• db.collection_name.updateOne()
• db.collection_name.updateMany()
• db.collection_name.replaceOne()

The following is an example of Update Operations in MongoDB.

4.Delete Operations in MongoDB


MongoDB Delete Operations are used to delete the Documents from the Collection.

The following methods are used to perform the Delete Operations in MongoDB.

• db.collection.deleteOne()
• db.collection.deleteMany()

The following is an example of Delete Operations in MongoDB.

RESULT:

Thus the Document based Database created and executed CRUD operations using
MONGODB

You might also like