상세 컨텐츠

본문 제목

[Mongo DB] 데이터베이스 생성 / 조회 / 삭제

Developer

by South Korea life 2021. 1. 12. 17:16

본문

728x90
반응형
  • 데이터베이스 생성
    > use "생성할 DB이름"
# 생성할 데이터베이스 이름: test_database
use test_database

 

  • 전체 데이터베이스 조회
    > show dbs
show dbs

 

  • 데이터베이스 삭제
    > db.dropDatabase()
# 삭제할 데이터베이스 진입
use test_database
db.dropDatabase()

 

  • Collection 생성
# 생성할 collection 이름이 test_collection일 경우...
db.createCollection("test_collection")

 

  • Collection 조회
    > show collection
# 사용할 데이터베이스 진입
use test_database

show collections

 

  • Collection 삭제
# 데이터베이스 진입 (데이터베이스 이름: test_database)
use test_database

# 삭제할 collection 이름: test_collection
db.test_collection.drop()

 

728x90
반응형

관련글 더보기

댓글 영역