The find() Method To query data from MongoDB collection, you need to use MongoDB's find() method. Syntax The basic syntax of find() method is as follows − >db.COLLECTION_NAME.find() find() method will display all the documents in a non-structured way. Example Assume we have created a collection named mycol as − > use sampleDB switched to db sampleDB > db . createCollection ( "mycol" ) { "ok" : 1 } > And inserted 3 documents in it using the insert() method as shown below − > db . mycol . insert ([ { title : "MongoDB Overview" , description : "MongoDB is no SQL database" , by : "tutorials point" , url : "http://www.tutorialspoint.com" , tags : [ "mongodb" , "database" , "NoSQL" ], likes : 100 }, { title : "NoSQL Database" , description : "NoSQL database doesn't have tables" , by : "tutoria...
Indexes are special lookup tables that the database search engine can use to speed up data retrieval. Simply put, an index is a pointer to data in a table. An index in a database is very similar to an index in the back of a book. For example, if you want to reference all pages in a book that discusses a certain topic, you first refer to the index, which lists all the topics alphabetically and are then referred to one or more specific page numbers. An index helps to speed up SELECT queries and WHERE clauses, but it slows down data input, with the UPDATE and the INSERT statements. Indexes can be created or dropped with no effect on the data. Creating an index involves the CREATE INDEX statement, which allows you to name the index, to specify the table and which column or columns to index, and to indicate whether the index is in an ascending or descending order. Indexes can also be unique, like the UNIQU...
PostgreSQL numeric functions are used primarily for numeric manipulation and/or mathematical calculations. The following table details the numeric functions − ABS(X) The ABS() function returns the absolute value of X. Consider the following example − testdb =# SELECT ABS ( 2 ); +---------------------------------------------------------+ | ABS ( 2 ) | +---------------------------------------------------------+ | 2 | +---------------------------------------------------------+ 1 row in set ( 0.00 sec ) testdb =# SELECT ABS (- 2 ); +---------------------------------------------------------+ | ABS ( 2 ) | +---------------------------------------------------------+ | 2 | +---------------------------------------------------------+ 1 row in set ( 0.00 se...
Comments
Post a Comment