如何在数据库之间切换?或者,更具体地说,如果打开了多个数据库,我将如何指定针对哪个数据库运行查询?
thufir@dur:~/basex$
thufir@dur:~/basex$ basex
[warning] /usr/bin/basex: Unable to locate /usr/share/java/jing.jar in /usr/share/java
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
>
> LIST
Name Resources Size Input Path
----------------------------------------------------------
books99 1 61253 /home/thufir/basex/db.books.xml
foo 1 61253 /home/thufir/basex/db.books.xml
new 1 61253 /home/thufir/basex/db.books.xml
3 database(s).
>
> OPEN foo
Database 'foo' was opened in 72.11 ms.
>
> OPEN new
Database 'new' was opened in 16.43 ms.
>
> CLOSE foo
Stopped at , 1/6:
Syntax: CLOSE
Close current database.
Closes the currently opened database.
>
> CLOSE
Database 'new' was closed.
>
> exit
Enjoy life.
thufir@dur:~/basex$
目前,大多数情况下我只是从XQUERY /
控制台运行BaseX
,从而确定数据的存在。
答案 0 :(得分:0)
也许不是一个完整的答案,但是要针对特定数据库运行查询,请打开该数据库并运行查询:
thufir@dur:~/basex$
thufir@dur:~/basex$ basex
[warning] /usr/bin/basex: Unable to locate /usr/share/java/jing.jar in /usr/share/java
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
>
> LIST
Name Resources Size Input Path
----------------------------------------------------------------
books 1 61253 /home/thufir/basex/db.books.xml
bookstore 1 6164 /home/thufir/basex/db.bookstore.xml
2 database(s).
>
> OPEN books
Database 'books' was opened in 67.74 ms.
>
> XQUERY /bookstore/book/title
Query executed in 217.72 ms.
>
> OPEN bookstore
Database 'bookstore' was opened in 2.2 ms.
>
> XQUERY /bookstore/book/title
<title lang="en">Everyday Italian</title>
<title lang="en">Harry Potter</title>
<title lang="en">XQuery Kick Start</title>
<title lang="en">Learning XML</title>
Query executed in 6.08 ms.
>
> OPEN books
Database 'books' was opened in 2.48 ms.
>
> XQUERY /bookstore/book/title
Query executed in 1.09 ms.
>
> exit
Have a nice day.
thufir@dur:~/basex$
值得注意的是,永远不要关闭数据库。我想上下文是最近打开的哪个数据库?