参考:https://stackoverflow.com/questions/9790049/numeric-collection-name-remove
Mongo shell中,当操作的集合名如果是数字的话,通过常规的操作方法,会报错,如下:
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
那么,如何使用的正确姿势是怎么样的呢?
如下:
db.getCollection('1234').drop()
使用db.getCollection()方法即可获取集合名字为数字的集合了。
文章的脚注信息由WordPress的wp-posturl插件自动生成
微信扫一扫,打赏作者吧~


![[原创]CentOS 6.5编译C++_MongoDB驱动](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2016/08/QQ截图20160801144415.png&w=280&h=210&zc=1)