Patrick Hoeffel
Patrick Hoeffel

Reputation: 113

How to run a SQL Script that builds my DB and schema in OrientDB?

I'm using OrientDB 2.0.2. I'm writing a SQL script that will create a new DB, construct the schema, and then populate the DB with static initial data. I know that the database will be automatically created if I simply start loading data, and that classes will automatically be created if I start inserting records, but I want to make sure that my classes have the right inheritance and Properties and Indexes before I begin my data load.

The SQL syntax is easy - I just need to know how to run the SQL script from the command line in order to instantiate the the DB, as if I were deploying a new instance of my DB at a new location, or for a new customer.

Thanks.

Upvotes: 3

Views: 2701

Answers (2)

Aiden Zhao
Aiden Zhao

Reputation: 574

According to the latest doc, you can do below:

  1. sh console.sh
  2. orientdb> LOAD SCRIPT /path/to/scripts/data.osql

Here is the link: https://orientdb.com/docs/3.1.x/console/Console-Command-Load-Script.htm

Upvotes: 0

rmuller
rmuller

Reputation: 12859

Assuming you installed OrientDB in the base directory ORIENTDB_HOME, then go to the $ORIENTDB_HOME/bin directory. In this directory, execute the OrientDB SQL Script with the simple command:

*nux:

$ ./console.sh myscript.osql

Windows:

> console.bat myscript.osql

mysql.osql is a simple text file, containing all SQL command (.oslq is a typical file extension for OrientDB SQL scripts).

See documentation for details how to create a new database. Example:

CREATE DATABASE plocal:/usr/local/orient/databases/demo/demo

or

CREATE DATABASE remote:localhost/trick root verySecretPassword

Upvotes: 6

Related Questions