找到 1660 篇文章 關於大資料分析

如何使用“like”查詢MongoDB?

Nancy Den
更新於 2019年7月30日 22:30:25

2K+ 次瀏覽

您可以輕鬆地使用“like”查詢MongoDB:db.yourCollectionName.find({"yourFieldName" : /.*yourMatchingValue.*/}).pretty();為了理解上述語法,讓我們建立一個包含一些文件的集合。這裡,我們有一個名為“employee”的集合。查詢如下:> db.employee.insert({"EmployeeName":"John", "EmployeeSalary":450000}); WriteResult({ "nInserted" : 1 }) > db.employee.insert({"EmployeeName":"Carol", "EmployeeSalary":150000}); WriteResult({ "nInserted" : 1 }) > db.employee.insert({"EmployeeName":"James", "EmployeeSalary":550000}); WriteResult({ "nInserted" : 1 }) > db.employee.insert({"EmployeeName":"Jace", "EmployeeSalary":670000}); WriteResult({ "nInserted" : 1 }) > db.employee.insert({"EmployeeName":"Larry", "EmployeeSalary":1000000}); WriteResult({ "nInserted" : 1 })現在您可以使用find()方法顯示集合中的所有文件。查詢如下:> db.employee.find().pretty();以下是輸出:{    "_id" : ObjectId("5c6c0b2e68174aae23f5ef59"),   ... 閱讀更多

在MongoDB中查詢兩個日期之間的物件?

Nancy Den
更新於 2019年7月30日 22:30:25

3K+ 次瀏覽

使用運算子$gte和$lt在MongoDB中查詢兩個日期之間的物件。為了理解這些運算子,讓我們建立一個集合。在這裡建立一個集合:>db.order.insert({"OrderId":1, "OrderAddrees":"US", "OrderDateTime":ISODate("2019-02-19")}; WriteResult({ "nInserted" : 1 }) >db.order.insert({"OrderId":2, "OrderAddrees":"UK", "OrderDateTime":ISODate("2019-02-26")}; WriteResult({ "nInserted" : 1 })使用find()方法顯示集合中的所有文件。查詢如下:> db.order.find().pretty();以下是輸出:{    "_id" : ObjectId("5c6c072068174aae23f5ef57"),    "OrderId" : 1,    "OrderAddrees" : "US",    "OrderDateTime" : ISODate("2019-02-19T00:00:00Z") } {    "_id" : ObjectId("5c6c073568174aae23f5ef58"),    "OrderId" : 2,    "OrderAddrees" : "UK",    "OrderDateTime" : ISODate("2019-02-26T00:00:00Z") }這裡的查詢 ... 閱讀更多

使用另一個欄位的值更新MongoDB欄位?

Krantik Chavan
更新於 2019年7月30日 22:30:25

2K+ 次瀏覽

您可以使用聚合函式來使用另一個欄位的值更新MongoDB欄位。在這裡,我們將建立兩個集合:name學生資訊集合建立包含文件的第一個集合的查詢如下:> db.name.insert({"FirstName":"John", "LastName":"Smith"}); WriteResult({ "nInserted" : 1 })現在您可以使用find()方法顯示集合中的所有文件。查詢如下:> db.name.find().pretty();以下是顯示集合“name”文件的輸出:{    "_id" : ObjectId("5c6c00dd68174aae23f5ef55"),    "FirstName" : "John",    "LastName" : "Smith" } 集合建立包含文件的第二個集合的查詢如下:> db.studentInformation.insert({"StudentFirstName":"Carol", "StudentLastName":"Taylor"}); WriteResult({ "nInserted" : 1 })現在 ... 閱讀更多

僅檢索MongoDB集合中物件陣列中已查詢的元素?

Krantik Chavan
更新於 2019年7月30日 22:30:25

256 次瀏覽

您可以使用投影運算子$elemMatch來過濾MongoDB集合中物件陣列中已查詢的元素。為了僅檢索MongoDB中物件陣列中已查詢的元素,讓我們首先建立一個包含文件物件陣列的集合。查詢如下:> db.objectArray.insert({"Persons":[    {"PersonName":"Adam", "PersonSalary":25000}, {"PersonName":"Larry", "PersonSalary":27000    }]});    WriteResult({ "nInserted" : 1 }) > db.objectArray.insert({"Persons":[    {"PersonName":"David", "PersonSalary":32000}, {"PersonName":"Carol", "PersonSalary":77000    }]});    WriteResult({ "nInserted" : 1 })現在您可以使用find()顯示所有文件。查詢如下:> db.objectArray.find().pretty();以下是輸出:{    "_id" : ObjectId("5c6bfadc68174aae23f5ef53"),    "Persons" ... 閱讀更多

如何從MongoDB集合中檢索文件?

Krantik Chavan
更新於 2019年7月30日 22:30:25

1K+ 次瀏覽

要從MongoDB集合中檢索文件,您需要使用find()方法。語法如下:db.yourCollectionName.find();上述語法將返回MongoDB集合中的所有文件。為了理解上述語法,讓我們建立一個包含文件的集合。建立文件的查詢如下:> db.retrieveAllStudents.insertOne({"StudentId":"STUD101", "StudentName":"David", "StudentAge":24}); {    "acknowledged" : true, "insertedId" : ObjectId("5c6bf5cf68174aae23f5ef4e") } > db.retrieveAllStudents.insertOne({"StudentId":"STUD102", "StudentName":"Carol", "StudentAge":22}); {    "acknowledged" : true, "insertedId" : ObjectId("5c6bf5e968174aae23f5ef4f") } > db.retrieveAllStudents.insertOne({"StudentId":"STUD103", "StudentName":"Maxwell", "StudentAge":25}); {    "acknowledged" : true, "insertedId" : ObjectId("5c6bf5f768174aae23f5ef50") } > db.retrieveAllStudents.insertOne({"StudentId":"STUD104", "StudentName":"Bob", "StudentAge":23}); {    "acknowledged" : true, "insertedId" : ... 閱讀更多

如何刪除MongoDB集合中的所有文件?

Krantik Chavan
更新於 2019年7月30日 22:30:25

578 次瀏覽

如果您想刪除集合中的所有文件,您可以使用deleteMany()。讓我們首先建立一個集合並向其中插入一些文件:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })現在顯示集合中的所有文件。查詢如下:> db.deleteDocumentsDemo.find().pretty();以下是輸出:{    "_id" : ObjectId("5c6ab0e064f3d70fcc914805"),    "Name" : "Larry",    "Age" : 23 } {    "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"),    "Name" : "Mike",    "Age" : 21 } {    "_id" : ObjectId("5c6ab0f864f3d70fcc914807"),    "Name" ... 閱讀更多

如何使用deleteOne()方法刪除MongoDB集合中的文件?

Daniol Thomas
更新於 2019年7月30日 22:30:25

258 次瀏覽

要刪除MongoDB集合中的文件,您可以使用deleteOne()方法。讓我們首先建立一個集合並向其中插入一些文件:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })現在顯示集合中的所有文件。查詢如下:> db.deleteDocumentsDemo.find().pretty();以下是輸出:{    "_id" : ObjectId("5c6ab0e064f3d70fcc914805"),    "Name" : "Larry",    "Age" : 23 } {    "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"),    "Name" : "Mike",    "Age" : 21 } { "_id" : ObjectId("5c6ab0f864f3d70fcc914807"), "Name" : "Sam", ... 閱讀更多

如何從MongoDB集合中刪除文件?

Daniol Thomas
更新於 2019年7月30日 22:30:25

354 次瀏覽

要從MongoDB集合中刪除文件,您需要使用remove()方法。語法如下:db.yourCollectionName.remove(yourDeleteValue);這裡,讓我們建立一個包含一些文件的集合。查詢如下:>db.deleteDocuments.insert({"UserId":1, "UserName":"Bob", "UserTechnicalSubject":"Introducti on to PL/SQL"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":2, "UserName":"Carol", "UserTechnicalSubject":"Introduction to MongoDB"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":3, "UserName":"John", "UserTechnicalSubject":"Introduction to MySQL"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":4, "UserName":"Maxwell", "UserTechnicalSubject":"Introduction to SQL Server"}); WriteResult({ "nInserted" : 1 })您可以使用find()命令顯示我們上面建立的集合中的所有文件。查詢如下:> db.deleteDocuments.find().pretty();以下是 ... 閱讀更多

如何將新文件插入資料庫中MongoDB集合?

Daniol Thomas
更新於 2019年7月30日 22:30:25

251 次瀏覽

要將新文件插入 MongoDB 集合中,需要使用 `insert()` 方法或 `save()` 方法。案例 1:使用 `insert()` 方法。語法如下:db.yourCollectionName.insert(yourDocument);案例 2:使用 `save()` 方法。語法如下:db.yourCollectionName.save(yourDocument);在上述語法中,如果您的集合名不存在,則 MongoDB 將建立一個新集合並將文件插入到該集合中。對於上面討論的兩種情況,插入新文件的查詢如下。案例 1:使用 `insert()` 方法。查詢如下:> db.userInformation.insert({    ... "Name":"John",    ... Age:30,    ... isStudent:false,    ... "Subjects":["Introduction to java", "Introduction to MongoDB"]    ... ... 閱讀更多

關係資料庫管理系統 (RDBMS) 的未來

Amit Diwan
更新於 2024年6月25日 16:32:16

瀏覽量:603

如今,大資料和 NoSQL 是資料庫解決方案的首選,但這並不意味著 RDBMS 的關鍵特性將會消失。由於過去幾年產生了 90% 的世界資料,因此在不久的將來,對 RDBMS 的需求不會消失。正如研究公司 Gartner 所述,RDBMS 市場正以每年 9% 的速度增長。RDBMS 旨在處理組織化資料。NoSQL 和大資料可能是首選,但 RDBMS 的重要性在不久的將來不會消失。現在,大規模管理資料需要大資料等技術,但 RDBMS 仍然... 閱讀更多

廣告
© . All rights reserved.