In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
= = basic operation command of mongodb =
DDL operation =
Create the schema: use Schema; create an object in Schema to db.createCollection ("CollectionName"). Equivalent to create database DBName
Create a collection: db.createCollection ("test"); equivalent to the creation table create table TableName () in DBMS
Showcase architecture: show dbs; is equivalent to show databases in mysql
Show the number of collections: show collections; show tables
Delete the current architecture: use Schema; db.dropDatabase (); drop database DBName
Modify the collection name: db.CollectionName.renameCollection ("NewName"); similar to alter table oldTable rename to NewTable in mysql
Delete collection: db.collections.drop (); similar to drop table tableName in mysql
View the current DB:db
User-related actions =
Add user: db.addUser ("UserName", "PWD")
Verify that the user has been added successfully: db.auth ("UserName", "PWD")
Delete user: db.removUsers ("testUser")
Permission related:
Http://blog.itpub.net/22664653/viewspace-715617/
DML operation =
Query collection: db.CollectionName.find ({}); equivalent to select * from TableName
Equality condition query: db.CollectionName.find ({key01:value01}); equivalent to select * from TableName where key01=value01
Different values of the query field (deduplicated): db.CollectionName.distinct ("Key") is similar to select distinct (key) from table
Fuzzy query: db.collections.find ({key:/ang/}); select * from tableName where key like'% ang%'
: db.collections.find ({key:/ ^ ang /}); select * from tableName where key like 'ang%'
: db.collections.find ({key:/g$/}); select * from tableName where key like'% ang'
Query the specified list: db.collections.find ({}, {key01:false,key02:true,key03:true}); select key02,key03 from tableName
Range lookup: db.collections.find ({key01: {$gt:20}}); select * from tableName where key01 > 20
: db.collections.find ({key01: {$lge:20}}); select * from tableName where key01 > = 20
: db.collections.find ({key01: {$lt:20}}); select * from tableName where key01 < 20
: db.collections.find () {key01: {$lte:20}}; select * from tableName where key01 = 24 and key01
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.