{"id":822,"date":"2014-12-18T23:42:21","date_gmt":"2014-12-18T23:42:21","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=822"},"modified":"2014-12-18T23:42:21","modified_gmt":"2014-12-18T23:42:21","slug":"mongodb-for-sql-users","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2014\/12\/18\/mongodb-for-sql-users\/","title":{"rendered":"MongoDB for SQL users"},"content":{"rendered":"<p>Here&#8217;s a Quick Reference to get started<\/p>\n<p><\/p>\n<table class=\"wptable rowstyle-alt\" id=\"wptable-5\"  cellspacing=\"1\">\n\t<thead>\n\t<tr>\n\t\t<th class=\"sortable\" style=\"width:160px\" align=\"left\">Description<\/th>\n\t\t<th class=\"sortable\" style=\"width:190px\" align=\"left\">SQL<\/th>\n\t\t<th class=\"sortable\" style=\"width:190px\" align=\"left\">Mongo DB<\/th>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<\/thead>\n\t<tr>\n\t\t<td style=\"width:160px\" align=\"left\">Lingo 1<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">Table; Relation<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">Collection<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr class=\"alt\">\n\t\t<td style=\"width:160px\" align=\"left\">Lingo 2<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">Row; Record; Tuple<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">Document<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr>\n\t\t<td style=\"width:160px\" align=\"left\">List Databases<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">SHOW databases<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">show databases<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr class=\"alt\">\n\t\t<td style=\"width:160px\" align=\"left\">List Tables<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">SHOW tables<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">show collections<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr>\n\t\t<td style=\"width:160px\" align=\"left\">Switch to a DB<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">USE db<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">use db<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr class=\"alt\">\n\t\t<td style=\"width:160px\" align=\"left\">Show Table Data<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">SELECT * FROM table<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">db.collection.find.pretty()<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr>\n\t\t<td style=\"width:160px\" align=\"left\">Filter Table Data<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">WHERE colum = 'value'<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">db.collection.find({'column':'value'})<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr class=\"alt\">\n\t\t<td style=\"width:160px\" align=\"left\">Select Columns<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">SELECT col1, col2<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">db.collection.find({},{col1:1, col2:1})<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr>\n\t\t<td style=\"width:160px\" align=\"left\">Delete Rows<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">DELETE FROM table WHERE col='val'<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">db.collection.remove({'col':'val'})<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr class=\"alt\">\n\t\t<td style=\"width:160px\" align=\"left\">Get Rid of a Table<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">DROP table<\/td>\n\t\t<td style=\"width:190px\" align=\"left\">db.collection.drop()<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n\t<tr>\n\t\t<td style=\"width:160px\" >&nbsp;<\/td>\n\t\t<td style=\"width:190px\" >&nbsp;<\/td>\n\t\t<td style=\"width:190px\" >&nbsp;<\/td>\n\t\t<td style=\"width:30px\" >&nbsp;<\/td>\n\t<\/tr>\n<\/table><p>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a Quick Reference to get started Description SQL Mongo DB &nbsp; Lingo 1 Table; Relation Collection &nbsp; Lingo 2 Row; Record; Tuple Document &nbsp; List Databases SHOW databases show databases &nbsp; List Tables SHOW tables show collections &nbsp; Switch to a DB USE db use db &nbsp; Show Table Data SELECT * FROM table [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,6],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/822"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=822"}],"version-history":[{"count":2,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/822\/revisions"}],"predecessor-version":[{"id":824,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/822\/revisions\/824"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=822"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}