mongo常用語法

2022-06-28 14:00:16 字數 1175 閱讀 7290

首先要能進入控制台,進不去自己解決。

基本操作:

show users:顯示使用者

show dbs:顯示資料庫列表 

use 切換/建立資料庫

show collections:顯示當前資料庫中的集合(類似關聯式資料庫中的表) 

db.help():顯示資料庫操作命令,裡面有很多的命令 

db..help()

db.find()

db..find( )

常用語句:

匯入匯出檔案到資料庫

mongoexport -d test -c students -o students.dat

mongoexport -d test -c students --csv -f classid,name,age -o students_csv.dat  

建立資料庫

use #建立集合時自動建立use的資料庫

db.clonedatabase(「127.0.0.1」) 3從指定機器上轉殖資料庫到當前use的資料庫

db.getname() #顯示當前資料庫

db.stats() 顯示當前db狀態

db.version()

刪除資料庫

db.dropdatabase()

修改資料庫

db.repairdatabase()#修復資料庫

使用者管理

db.adduser("name")#

db.adduser("username", "pwd123", true)#新增使用者、設定密碼、是否唯讀

db.auth("username", "123123") #資料庫認證、安全模式

show users #顯示當前所有使用者

db.removeuser("username") #刪除所有使用者

db.getpreverror()#查詢錯誤資訊

db.reseterror() #清空錯誤日誌

建立集合

刪除集合

修改集合

查詢集合資料/集合名稱

db.getcollection("account")#查詢指定集合

db.getcollectionnames()#查詢當前資料庫的所有集合

db.printcollectionstats()#顯示當前db索引狀態

db.find()#查詢指定集合的資料

mysql常用語法 MySQL常用語法

更新資料 update 表名 set 健名 更改的值 where 建 刪除資料 delete from 表名 where 索引 create index 索引名稱 on 表名 鍵名 建立試圖 create view 檢視名 鍵,鍵 as select matchno,abs won lost fro...

mysql基本常用語法 mysql 常用語法

1.1.開啟 service mysql start 1.2.關閉 service mysql stop 1.3.重啟 service mysql restart 2.1.密碼明文 語法 mysql u使用者名稱 p使用者密碼 舉例 mysql uroot p123456 2.2.密碼密文 語法 m...

wiki常用語法

公司啟用了streber執行部分專案管理工作。streber基於wiki系統建立。在streber中,我們可以建立專案 project 可以為專案建立milestone task等等。與其他專案管理系統一樣,可以為每乙個task分配資源,指定執行時間。由於streber基於wiki組建,具備了wik...