File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 1+
2+ .. example ::
3+
4+ If the database ``salesDB `` already exists MongoDB will
5+ return an error if if you attempt to create a database named ``salesdb ``.
6+
7+ .. code-block :: javascript
8+
9+ mixedCase = db .getSiblingDB (' salesDB' )
10+ lowerCase = db .getSiblingDB (' salesdb' )
11+
12+ mixedCase .retail .insertOne ({ " widgets" : 1 , " price" : 50 })
13+
14+ The operation succeeds and :method: `~db.collection.insertOne() ` implicitly
15+ creates the ``SalesDB `` database.
16+
17+ .. code-block :: javascript
18+
19+ lowerCase .retail .insertOne ({ " widgets" : 1 , " price" : 50 })
20+
21+ The operation fails. :method: `~db.collection.insertOne() ` tries to
22+ create a ``salesdb `` database and is blocked by the naming
23+ restriction. Database names must differ on more than just case.
24+
25+ .. code-block :: javascript
26+
27+ lowerCase .retail .find ()
28+
29+ This operation does not return any results because the database names are case
30+ sensitive. There is no error because :method: `~db.collection.find() ` doesn't
31+ implicitly create a new database.
Original file line number Diff line number Diff line change @@ -36,8 +36,11 @@ Naming Restrictions
3636
3737.. limit:: Database Name Case Sensitivity
3838
39- Since database names are case *insensitive* in MongoDB, database
40- names cannot differ only by the case of the characters.
39+ Database names are case-sensitive in MongoDB. They also have an
40+ additional restriction, case cannot be the only difference between
41+ database names.
42+
43+ .. include:: /includes/fact-case-sensitivity-limitation-code.rst
4144
4245.. limit:: Restrictions on Database Names for Windows
4346
You can’t perform that action at this time.
0 commit comments