Standalone Mode

From BaseX Documentation

Jump to: navigation, search

This page is part of the Getting Started Section. BaseX offers a standalone console mode from which all database commands can be executed. The article on the Database Server provides numerous examples for running commands in the console mode (note that the GUI does not interact with the client/server architecture).

Contents

[edit] Startup

First of all, please launch a standalone version of BaseX: double click on the BaseX icon, or run the basex script. Follow this link for more information (or check out the additional command-line options).

[edit] Create a Database

> CREATE DB factbook factbook.xml

factbook is the name of the database
factbook.xml is the initial input of the database
Where is the database stored?

By default, databases are stored in the BaseXData directory, which is located in your home folder. Depending on your Configuration, the location of your home folder varies. For example, on a Mac it's /Users/John, if your name is John. If you are working with the ZIP or EXE distribution, the directory will be named data and reside in the application directory.

[edit] Execute a Query

The XQUERY command lets you run a query.

> XQUERY //country

> RUN /Users/John/query.xq

[edit] Database Commands

> LIST

> OPEN factbook

> INFO

> XQUERY db:open("factbook")//country

> CLOSE

> DROP DB factbook

[edit] Multiple Resources

One database can contain not only a single, but millions of documents. All documents can have a different structure.

With the following commands, you can create an empty database and add two documents. It is also possible to address resources via URLs:

> CREATE DB store
> ADD factbook.xml
> ADD http://files.basex.org/xml/xmark.xml

> DELETE factbook.xml

Make sure that the database, which contains the addressed document, is currently opened.

[edit] Backup and Restore

> CREATE BACKUP factbook

> RESTORE factbook

The backup file is stored in the database directory. The contains the name of the database and a timestamp: [db-name]-[timestamp].zip. If a database is restored, and if several backups exist, the backup with the newest timestamp is taken.

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export