找到 1660 篇文章,關於大資料分析
2K+ 次瀏覽
您可以使用 `$regex` 運算子來檢查 MongoDB 中的欄位是否包含某個字串。語法如下:`db.yourCollectionName.findOne({"yourFieldName":{$regex:".*yourValue.*"}})`。為了理解上述概念,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下:`> db.checkFieldContainsStringDemo.insertOne({"Id":1, "Name":"John"});` ... 閱讀更多
2K+ 次瀏覽
要在 MongoDB 中查詢長度大於特定值的字串,請使用 `$where` 運算子。語法如下:`db.yourCollectionName.find({$where:'this.yourStringFieldName.length > yourIntegerValue'}).pretty();` 為了理解上述概念,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下:`> db.stringFieldLengthDemo.insertOne({"UserId":1, "UserName":"Adam Smith"});` ... 閱讀更多
32K+ 次瀏覽
要在 MongoDB 中搜索物件陣列,可以使用 `$elemMatch` 運算子。此運算子允許我們從陣列物件中搜索多個元件。為了理解上述概念,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下:`> db.searchArrayDemo.insertOne({"EmployeeFirstName":"Adam", "EmployeeLastName":"Smith", "EmployeeDateOfBirth":new ISODate("1992-01-31 13:45:10"), ... "EmployeeSkills":["Spring and Hibernate Framework", "Machine Learning"], ... "EmployeeDetails":[ ... { ... "EmployeePerformanceArea":"Java", ... "Year":2001 ... }, ... { ... ... 閱讀更多
2K+ 次瀏覽
在 MongoDB 中,不存在將集合從一個數據庫複製到另一個數據庫的命令。要實現此目的,請使用以下概念:`db.yourCollectionName.find().forEach(function(yourVariableName){ db.getSiblingDB('yourDestinationDatabase')['yourCollectionName'].insert(yourVariableName); });` 讓我們在 test 資料庫中建立一個集合,並將此集合複製到另一個名為“sample”的資料庫。為了理解上述語法,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下:`> use test switched to db test > db.copyThisCollectionToSampleDatabaseDemo.insertOne({"User_Id":101, "UserName":"Larr y"});` ... 閱讀更多
192 次瀏覽
如果要列出特定資料庫中的所有集合,則需要先切換資料庫。查詢如下:`> use sample; switched to db sample > db.getCollectionNames();` 輸出如下:`[ "copyThisCollectionToSampleDatabaseDemo", "deleteDocuments", "deleteDocumentsDemo", "deleteInformation", "employee", "internalArraySizeDemo", "sourceCollection", "updateInformation", "userInformation" ]` 另一個查詢可以是:`> show collections;` 輸出如下:`copyThisCollectionToSampleDatabaseDemo deleteDocuments deleteDocumentsDemo deleteInformation employee internalArraySizeDemo sourceCollection updateInformation userInformation`
198 次瀏覽
要按升序排序,語法如下:`db.yourCollectionName.find().sort({yourField:1});` 為了理解這個概念,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下:`> db.sortingDemo.insertOne({"Value":100});` ... 閱讀更多
391 次瀏覽
您可以使用 MongoDB 中的 `distinct()` 方法來獲取不同的記錄值。語法如下:`db.yourCollectionName.distinct(“yourFieldName”);` 為了理解上述語法,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下:`> db.distinctRecordDemo.insertOne({"StudentId":1, "StudentName":"John", "StudentAge":21});` ... 閱讀更多
243 次瀏覽
您可以藉助聚合框架實現這一點。為了理解這個概念,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下所示:-> db.countGroupByDemo.insertOne({"StudentId":10, "StudentName":"John"}); { "acknowledged" : true, "insertedId" : ObjectId("5c7700871e9c5dd6f1f78296") } > db.countGroupByDemo.insertOne({"StudentId":10, "StudentName":"Carol"}); { "acknowledged" : true, "insertedId" : ObjectId("5c77008f1e9c5dd6f1f78297") } > db.countGroupByDemo.insertOne({"StudentId":20, "StudentName":"Sam"}); { "acknowledged" : true, "insertedId" : ObjectId("5c7700971e9c5dd6f1f78298") } > db.countGroupByDemo.insertOne({"StudentId":30, "StudentName":"Mike"}); { "acknowledged" : true, "insertedId" : ObjectId("5c7700a21e9c5dd6f1f78299") } > db.countGroupByDemo.insertOne({"StudentId":30, "StudentName":"David"}); { "acknowledged" : true, "insertedId" : ObjectId("5c7700aa1e9c5dd6f1f7829a") } ... 閱讀更多
2K+ 次瀏覽
您可以為此使用$ne(不等於)運算子。為了理解這個概念,讓我們建立一個包含文件的集合。建立包含文件的集合的查詢如下所示:-> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Larry", "StudentTechnicalSubject":["Java", "C"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76fe2f1e9c5dd6f1f78291") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Mike", "StudentTechnicalSubject":[]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76fe3b1e9c5dd6f1f78292") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Sam", "StudentTechnicalSubject":["MongoDB"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76fe491e9c5dd6f1f78293") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Carol", "StudentTechnicalSubject":[]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76fe521e9c5dd6f1f78294") } > db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"David", "StudentTechnicalSubject":["MySQL", "SQL Server"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76fe661e9c5dd6f1f78295") }顯示所有文件 ... 閱讀更多
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP