为什么80%的码农都做不了架构师?>>>   

1. Create Database in MongoDB

It’s strange to listen but true that MongoDB doesn’t provide any command to create databases. Then the question is how would we create database ?. The answer is – We don’t create database in MongoDB, we just need to use database with your preferred name and need to save a single record in database to create it.

List Databases – First check the current databases in our system.

# mongo
> show dbs;
admin  (empty)
local  0.078GB
test   0.078GB

Use New Database – 
Now if we want to create database with name exampledb. Just run following command and save a single record in database. After saving your first example, you will see that new database has been created.

> use exampledb;
> s = { Name : "TecAdmin.net" }
> db.testData.insert( s );

List Databases – 
Now if you list the databases, you will see the new database will be their with name exampledb.

> show dbs;
admin  (empty)
local  0.078GB
exampledb   0.078GB
test   0.078GB

2. Drop Database in MongoDB

MongoDB provides dropDatabase() command to drop currently used database with their associated data files. Before deleting make sure what database are you selected using db command.

> db
exampledb

Now if you execute dropDatabase() command. It will remove exampledb database.

> db.dropDatabase();
{ "dropped" : "exampledb", "ok" : 1 }

To delete MongoDB database from Linux command line or Shell Script – Use following command from

# mongo exampledb --eval "db.dropDatabase()"

转载于:https://my.oschina.net/liting/blog/1982066

How to Create and Drop database in MongoDB相关推荐

  1. Create and Drop Database, Create, Alter and Drop Tables, Select, Insert, Update, Delete Commands

    此文仅做自我学习记录用!!! Introduction (Descriptive) Content:- Creating and Maintaining Tables, Objectives, The ...

  2. MySQL数据库的基本操作-创建(create database)、选择(use)、查看(shows database)、删除(drop database)

    一.MySQL概述 MySQL是目前最流行的开源数据库,是完全网络化的跨平台关系型数据库系统,尤其与PHP,被称为黄金组合. MySQL的特点: 1.功能强大. 2.支持跨平台. 3.运行速度快. 4 ...

  3. MySQL删除数据库(DROP DATABASE语句)

    在 MySQL 中,当需要删除已创建的数据库时,可以使用 DROP DATABASE 或 DROP SCHEMA 语句.其语法格式为: DROP DATABASE [ IF EXISTS ] < ...

  4. 6、MySQL删除数据库(DROP DATABASE语句)

    当数据库不再使用时应该将其删除,以确保数据库存储空间中存放的是有效数据.删除数据库是将已经存在的数据库从磁盘空间上清除,清除之后,数据库中的所有数据也将一同被删除. 在 MySQL 中,当需要删除已创 ...

  5. mysql中 !40000 DROP DATABASE IF EXISTS `top_server` 这中注释有什么作用?

    需求描述: 今天在进行mysqldump实验,使用--add-drop-databases参数,于是在生成的SQL文件中,就出现了. /*!40000 DROP DATABASE IF EXISTS ...

  6. (笔记)Mysql命令drop database:删除数据库

    drop命令用于删除数据库. drop命令格式:drop database <数据库名>; 例如,删除名为 xhkdb的数据库: mysql> drop database xhkdb ...

  7. mysql 命令删库名,MySQL控制台删除数据库命令 drop database 数据库名

    MySQL控制台删除数据库命令 drop database 数据库名 分类:数据库| 发布:佚名| 查看: | 发表时间:2014/4/30 命令:drop database 例如:删除名为 camn ...

  8. sql语句(select,create,drop,alter,delete,insert,update,grant)

    SQL语言 关系型数据库常见对象 数据库:database 表:table 行:row 列:column 索引:index 视图:view 用户:user 权限:privilege SQL语言规范 S ...

  9. Python, SQL: Cannot drop database XXX because it is currently in use解决方法

    在使用pymssql连接SQL Server时遇到这个问题: pymssql.OperationalError: (3702, b'Cannot drop database "XXX&quo ...

  10. Oracle 10g新增DROP DATABASE命令

    在10g以前,要彻底删除数据库,只有两个方法,一个是利用DBCA图形化工具删除数据库,另外一个就是关闭数据库后,手工删除数据文件.控制文件以及日志文件的方法. 从10g开始,Oracle提供了DROP ...

最新文章

  1. IOS TextField设置大全
  2. java面试基础_Java面试基础
  3. python三大特征六大原则_面向对象程序设计(Object Oriented Programming)的三大特性,六大原则...
  4. Python学习入门基础教程(learning Python)--5.6 Python读文件操作高级
  5. CSS去除链接虚线(兼容IE6、IE7)
  6. Lead项目中简单分析卡号的编码规则
  7. 【存储】Android中的8种数据存储方式
  8. 【百战GAN】StyleGAN原理详解与人脸图像生成代码实战
  9. 内存占用率过高怎么办 一分钟解决
  10. Mybatis 官网地址
  11. Java modifier
  12. Android GPS中间层驱动开发调试
  13. AI开发者被疯抢,华为做了什么?
  14. 反击爬虫,前端工程师的脑洞可以有多大?
  15. linux下限制每个IP网速
  16. kafka踩坑、实践篇
  17. matlab 随机相位的正弦信号,利用MATLAB绘制随机相位正弦波.docx
  18. 记面试中问到的MySQL的SQL调优问题
  19. 2022二级建造师《施工管理》考前冲刺试题与答案
  20. 学习python的目的

热门文章

  1. openai-gpt_为什么GPT-3感觉像是编程
  2. 64位系统装32和64位oracle,64位系统安装32位Oracle developer
  3. php soapenv:server.userexception,SoapFault - faultcode: 'soap:Server' faultstring
  4. nvm 下载node 下载不下来_音乐下载 黄子韬爸妈可以不走吗
  5. 虚拟主机隐藏index.html,Nginx如何隐藏index.html
  6. labelcontrol 多行_ios – UISegmentedControl中的两行文本
  7. 项目-字典-更新字典分组
  8. Python基本数据类型之字典
  9. 《云云众声》第101期:众家发声 追求“中国特色”
  10. docker~学习笔记索引