[NoSQL][MongoDB] Truncate a collection

[Question] How do I truncate a collection in MongoDB or is there such a thing?

Right now I have to delete 6 large collections all at once and I'm stopping the server, deleting the database files and then recreating the database and the collections in it. Is there a way to delete the data and leave the collection as it is? The delete operation takes very long time. I have millions of entries in the collections.

[Answer]

To truncate a collection and keep the indexes use

 db.<collection>.remove({})

 

[출처] https://stackoverflow.com/questions/16493902/truncate-a-collection

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

 

 

 

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
공지 오라클 기본 샘플 데이터베이스 졸리운_곰 2014.01.02 25085
공지 [SQL컨셉] 서적 "SQL컨셉"의 샘플 데이타 베이스 SAMPLE DATABASE of ORACLE 가을의 곰을... 2013.02.10 24564
공지 [G_SQL] Sample Database 가을의 곰을... 2012.05.20 25943
1045 [MySQL] 트리거 (종류, 사용법, 삭제, 예제) 졸리운_곰 2023.07.19 24
1044 [MySQL] 트리거(Trigger)의 활용 file 졸리운_곰 2023.07.19 16
1043 [MySQL] 트리거(Trigger)란? 트리거 사용 예제 file 졸리운_곰 2023.07.19 104
1042 [AutoML][AutoKeras] [OSS] AutoKeras로 자동학습(AutoML) 하기 file 졸리운_곰 2023.07.02 12
» [NoSQL][MongoDB] Truncate a collection 졸리운_곰 2023.06.04 12
1040 [Tensorflow 2.0] 모델 저장하고 불러오기 졸리운_곰 2023.05.21 29
1039 [pytorch] Pytorch에서 학습한 모델 저장 및 불러오기 졸리운_곰 2023.05.21 11
1038 [MySQL] MySQL - 테이블 만들기 file 졸리운_곰 2023.05.13 29
1037 [R library] library(XML) # install.packages("XML") 인스톨 에러 졸리운_곰 2023.05.06 18
1036 [MySQL] MySQL Strict mode 끄기/켜기 졸리운_곰 2023.05.05 21
1035 [R 데이터 분석] Titanic: Machine Learning from Disaster (타이타닉 생존 예측) file 졸리운_곰 2023.04.29 55
1034 [R 데이터 분석] R 유명한 패키지 정리 졸리운_곰 2023.04.24 76
1033 [NoSQL] MongoDB 인증 모드 (password) 설정 졸리운_곰 2023.03.26 35
1032 [MySQL] [MySQL] 테이블 구조와 데이터 복사 (Table Structure and Data Copy) 졸리운_곰 2023.03.20 24
1031 [R 데이터 분석] Shiny : 대시보드 배포하기 file 졸리운_곰 2023.03.19 76
1030 [데이터 수집 및 전처리] (놀라운) 한글 데이터 짱! AwesomeKorean_Data file 졸리운_곰 2023.03.07 37
1029 [pytorch] Using BERT with Pytorch file 졸리운_곰 2023.03.06 28
1028 [pytorch] Full NMT model from pretrained BERT file 졸리운_곰 2023.03.06 16
1027 [기계학습][딥러닝] PyTorch Hello World 졸리운_곰 2023.02.12 23
1026 [PostgreSQL] 열을 행으로 전환 쿼리 졸리운_곰 2023.01.29 52
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED