- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6702 Articles for Database
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
319 Views
You can get documents with max attribute per group in a collection using $sort operator along with $group statement.To understand the concept further, let us create a collection with document. The query to create a collection with document is as follows −> db.maxAttributePerGroup.insertOne({"StudentFirstName":"John", "StudentLastName":"Smith ", "StudentAge":29, "StudentId":10}); { "acknowledged" : true, "insertedId" : ObjectId("5c76ee341e9c5dd6f1f78277") } > db.maxAttributePerGroup.insertOne({"StudentFirstName":"Carol", "StudentLastName":"Taylo r", "StudentAge":19, "StudentId":10}); { "acknowledged" : true, "insertedId" : ObjectId("5c76ee4e1e9c5dd6f1f78278") } > db.maxAttributePerGroup.insertOne({"StudentFirstName":"Adam", "StudentLastName":"Smit h", "StudentAge":34, "StudentId":20}); { "acknowledged" : true, "insertedId" : ObjectId("5c76ee631e9c5dd6f1f78279") } > db.maxAttributePerGroup.insertOne({"StudentFirstName":"Bob", "StudentLastName":"Taylor" , "StudentAge":58, "StudentId":20}); { ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
863 Views
In order to replace substring in MongoDB document, you can use the replace() function. To understand it further, let us create a collection with document. The query to create a collection with document is as follows −> db.replaceSubstringDemo.insertOne({"WebsiteURL":"www.gogle.com"}); { "acknowledged" : true, "insertedId" : ObjectId("5c76eaf21e9c5dd6f1f78276") }Display all documents from a collection with the help of find() method. The query is as follows −> db.replaceSubstringDemo.find().pretty();Output{ "_id" : ObjectId("5c76eaf21e9c5dd6f1f78276"), "WebsiteURL" : "www.gogle.com" }Here is the query to replace substring in MongoDB document −> db.replaceSubstringDemo.find({WebsiteURL:"www.gogle.com"}).forEach(function(url, k){ ... url.WebsiteURL=url.WebsiteURL.replace("www.gogle.com", "www.google.com"); ... db.replaceSubstringDemo.save(url) ... });Let us display the ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
635 Views
You can use $facet operator for this. To understand the concept, let us create a collection with document. The query to create a collection with document is as follows −> db.totalDocumentDemo.insertOne({"InstructorId":100, "InstructorName":"Larry", "InstructorFav ouriteSubject":["Java", "MongoDB", "Python"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76e6701e9c5dd6f1f78274") } > db.totalDocumentDemo.insertOne({"InstructorId":200, "InstructorName":"Sam", "InstructorFav ouriteSubject":["SQL Server", "C#", "Javascript"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c76e69c1e9c5dd6f1f78275") }Display all documents from a collection with the help of find() method. The query is as follows −> db.totalDocumentDemo.find().pretty();Output{ "_id" : ObjectId("5c76e6701e9c5dd6f1f78274"), "InstructorId" : 100, "InstructorName" : "Larry", "InstructorFavouriteSubject" : [ ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
1K+ Views
You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place holder (?) to which we need to set date value.a Date object representing the date value to be passed. The constructor of java.sql.Date class accepts a variable of long type representing the number of milliseconds from the epoch (standard base time I.e. January 1, 1970, 00:00:00 GMT).ExampleAssume we have created ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
164 Views
A BLOB is binary large object that can hold a variable amount of data with a maximum length of 65535 charactersThese are used to store large amounts of binary data, such as images or other types of files.A CLOB stands for Character Large Object in general, an SQL Clob is a built-in datatype is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters.Blob and Clob data types together are known as LOB (Large Object) datatypes. Following are the restrictions on these datatypes.Cannot compare: We cannot compare CLOB ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
12K+ Views
Blob and Clob together are known as LOB(Large Object Type). The following are the major differences between Blob and Clob data types.BlobClobThe full form of Blob is a Binary Large Object.The full form of Clob is Character Large Object.This is used to store large binary data.This is used to store large textual data.This stores values in the form of binary streams.This stores values in the form of character streams.Using this you can stores files like videos, images, gifs, and audio files.Using this you can store files like text files, PDF documents, word documents etc.MySQL supports this with the following datatypes:TINYBLOBBLOBMEDIUMBLOBLONGBLOBMySQL ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
959 Views
The ResultSet interface provides the methods named getClob() and getCharacterStream() to retrieve Clob datatype, In which the contents of a file are typically stored.These methods accept an integer representing the index of the column (or, a String value representing the name of the column) and retrieves the value at the specified column.The difference is the getClob() method returns a Clob object and the getCgaracterStream() method returns a Reader object which holds the contents of the Clob datatype.ExampleAssume we have created a table named Articles in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field | Type ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
4K+ Views
In general, the contents of a file are stored under Clob (TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT) datatype in MySQL database.JDBC provides support for the Clob datatype, to store the contents of a file in to a table in a database.The setCharacterStream() method of the PreparedStatement interface accepts an integer representing the index of the parameter and, a Reader object as a parameter.And sets the contents of the given reader object (file) as value to the parameter (place holder) in the specified index.Whenever you need to send very large text value you can use this method.Storing text file using JDBC:If you need to ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
489 Views
The ResultSet interface provides the method named getClob() to retrieve clob datatype from a table in a database. In addition to this it also provides a method named getCharacterStream()Like getClob() this method also accepts an integer representing the index of the column (or, a String value representing the name of the column) and retrieves the value at the specified column. The difference is unlike the getClob() method (which returns a Clob object) this method returns an object of the Reader class.ExampleAssume we have created a table named MyData in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field | Type ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
2K+ Views
Assume we already have a table named MyData in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+-------+ | Name | varchar(255) | YES | | NULL | | | Article | longtext | YES | | NULL | | +---------+--------------+------+-----+---------+-------+If you need to insert ... Read More