Numeric Collection Name Remove

六月ゝ 毕业季﹏ 提交于 2019-11-27 07:39:24

问题


How can you drop a numeric collection from MongoDB?

PRIMARY> db.123456789011.remove({});
Tue Mar 20 08:42:51 SyntaxError: missing ; before statement (shell):1

PRIMARY> db.123456789011.drop({});
Tue Mar 20 08:43:13 SyntaxError: missing ; before statement (shell):1

Was created through a PHP script.. now I can't figure out how to remove this..

Thoughts?

Thank you


回答1:


This should work:

   db["123456789011"].drop()



回答2:


I was having the same issue with a collection generated by a java class

db["1234"].drop()
Wed Jul  9 14:57:39.358 TypeError: Cannot call method 'drop' of undefined

and at the end used the following command to remove it.

db.getCollection('1234').drop()


来源:https://stackoverflow.com/questions/9790049/numeric-collection-name-remove

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!