Skip to content

Commit d4b1631

Browse files
committed
DOCS-5898 add examples for dropDatabase
1 parent 15335ec commit d4b1631

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

source/reference/command/dropDatabase.txt

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,43 @@ dropDatabase
44

55
.. default-domain:: mongodb
66

7+
Definition
8+
----------
9+
710
.. dbcommand:: dropDatabase
811

912
The :dbcommand:`dropDatabase` command drops the current database, deleting
1013
the associated data files.
1114

12-
.. include:: /includes/fact-drop-database-users.rst
13-
14-
To run this command, issue the ``use <database>`` command in the shell,
15-
replacing ``<database>`` with the name of the database you wish to delete.
16-
Then use the following command form:
15+
The command has the following form:
1716

1817
.. code-block:: javascript
1918

2019
{ dropDatabase: 1 }
2120

22-
The :program:`mongo` shell also provides the following equivalent helper method
21+
The :program:`mongo` shell also provides the helper method
2322
:method:`db.dropDatabase()`.
2423

25-
.. include:: /includes/warning-blocking-global.rst
24+
Behavior
25+
--------
26+
27+
.. include:: /includes/warning-blocking-global.rst
28+
29+
.. include:: /includes/fact-drop-database-users.rst
30+
31+
Example
32+
-------
33+
34+
The following example in the :program:`mongo` shell uses the ``use
35+
<database>`` operation to switch the current database to the ``temp``
36+
database and then uses the :dbcommand:`dropDatabase` command to drop
37+
the ``temp`` database:
38+
39+
.. code-block:: javascript
40+
41+
use temp
42+
db.runCommand( { dropDatabase: 1 } )
2643

27-
.. write-lock
44+
.. write-lock
2845

2946
.. seealso:: :dbcommand:`dropAllUsersFromDatabase`

source/reference/method/db.dropDatabase.txt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,34 @@ db.dropDatabase()
44

55
.. default-domain:: mongodb
66

7+
Definition
8+
----------
9+
710
.. method:: db.dropDatabase()
811

9-
Removes the current database. Does not change the current database,
10-
so the insertion of any documents in this database will allocate a
11-
fresh set of data files.
12+
Removes the current database, deleting the associated data files.
13+
14+
Behavior
15+
--------
16+
17+
The :method:`db.dropDatabase()` wraps the :dbcommand:`dropDatabase`
18+
command.
19+
20+
.. include:: /includes/warning-blocking-global.rst
21+
22+
.. include:: /includes/fact-drop-database-users.rst
23+
24+
Example
25+
-------
26+
27+
The following example in the :program:`mongo` shell uses the ``use
28+
<database>`` operation to switch the current database to the ``temp``
29+
database and then uses the :method:`db.dropDatabase()` method to drops
30+
the ``temp`` database:
31+
32+
.. code-block:: javascript
1233

13-
.. include:: /includes/fact-drop-database-users.rst
34+
use temp
35+
db.dropDatabase()
1436

1537
.. seealso:: :dbcommand:`dropDatabase`

0 commit comments

Comments
 (0)