我在OSX上运行Mongodb时遇到问题。我已经安装了brew,当我尝试启动Mongodb服务器并输入mongo然后运行它让我出错:
declare @Spaces as Table
(
SummaryId int not null
,Space01 int not null
,Space02 int null
,Space03 int null
,Space04 int null
,Space05 int null
,Space06 int null
,Space07 int null
,Space08 int null
)
insert into @Spaces
(SummaryId, Space01)
select s.id, charindex(' ',s.summary)
from dbo.[Summary] s
update sp set sp.Space02 = charindex(' ', s.summary, sp.Space01 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space03 = charindex(' ', s.summary, sp.Space02 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space04 = charindex(' ', s.summary, sp.Space03 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space05 = charindex(' ', s.summary, sp.Space04 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space06 = charindex(' ', s.summary, sp.Space05 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space07 = charindex(' ', s.summary, sp.Space06 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space08 = len(s.summary)+1 from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
--select * from @Spaces
declare @Names as Table
(
SummaryId int not null
,Name varchar(200) not null
)
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space01, sp.Space02 - sp.Space01) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space03, sp.Space04 - sp.Space03) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space05, sp.Space06 - sp.Space05) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space07, sp.Space08 - sp.Space07) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
--select * from @Names
select n.SummaryId, replace(n.Name, '*','') as Name from @Names n where charindex('*',n.Name) > 0
select n.SummaryId, n.Name from @Names n where charindex('*',n.Name) = 0
你能给我一些有用的建议吗?
提前谢谢。
答案 0 :(得分:2)
mongo
是客户端shell,它不是服务器。使用mongod
命令启动MongoDB服务器。例如:
mongod --dbpath ~/mongodb/data
您也可以在操作系统启动时自动启动mongod
。您可以在此处找到相关说明:https://stackoverflow.com/a/17061202/236660
服务器启动后,您可以使用mongo
连接到服务器。
请注意,您也可以在不连接任何服务器的情况下运行mongo shell:
mongo --nodb
当然,你只能通过shell来做很多事情。