Category: orientdb

  • Khóa học miễn phí OrientDB – Disconnect Database nhận dự án làm có lương

    OrientDB – Disconnect Database



    This chapter explains how to disconnect to a particular database from the OrientDB command line. It closes the currently open database.

    The following statement is the basic syntax of the Disconnect command.

    DISCONNECT
    

    Note − You can use this command only after connecting to a particular database and it will only close the currently running database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will disconnect from demo database.

    You can use the following command to disconnect the database.

    orientdb {db = demo}> DISCONNECT
    

    If it is successfully disconnected, you will get the following output −

    Disconnecting to database [plocal:/opt/orientdb/databases/demo] with user ''admin''…OK
    orientdb>
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Connect Database nhận dự án làm có lương

    OrientDB – Connect Database



    This chapter explains how to connect to a particular database from the OrientDB command line. It opens a database.

    The following statement is the basic syntax of the Connect command.

    CONNECT <database-url> <user> <password>
    

    Following are the details about the options in the above syntax.

    <database-url> − Defines the URL of the database. URL contains two parts one is <mode> and the second one is <path>.

    <mode> − Defines the mode, i.e. local mode or remote mode.

    <path> − Defines the path to the database.

    <user> − Defines the user you want to connect to the database.

    <password> − Defines the password for connecting to the database.

    Example

    We have already created a database named ‘demo’ in the previous chapters. In this example, we will connect to that using the user admin.

    You can use the following command to connect to demo database.

    orientdb> CONNECT PLOCAL:/opt/orientdb/databases/demo admin admin
    

    If it is successfully connected, you will get the following output −

    Connecting to database [plocal:/opt/orientdb/databases/demo] with user ''admin''…OK
    Orientdb {db = demo}>
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Info Database nhận dự án làm có lương

    OrientDB – Info Database



    This chapter explains how to get information of a particular database from the OrientDB command line.

    The following statement is the basic syntax of the Info command.

    info
    

    Note − You can use this command only after connecting to a particular database and it will retrieve the information of only the currently running database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will retrieve the basic information from demo database.

    You can use the following command to disconnect the database.

    orientdb {db = demo}> info
    

    If it is successfully disconnected, you will get the following output.

    Current database: demo (url = plocal:/opt/orientdb/databases/demo)
    
    DATABASE PROPERTIES
    --------------------------------+---------------------------------------------+
     NAME                           | VALUE                                       |
    --------------------------------+---------------------------------------------+
     Name                           | null                                        |
     Version                        | 14                                          |
     Conflict Strategy              | version                                     |
     Date format                    | yyyy-MM-dd                                  |
     Datetime format                | yyyy-MM-dd HH:mm:ss                         |
     Timezone                       | Asia/Kolkata                                |
     Locale Country                 | IN                                          |
     Locale Language                | en                                          |
     Charset                        | UTF-8                                       |
     Schema RID                     | #0:1                                        |
     Index Manager RID              | #0:2                                        |
     Dictionary RID                 | null                                        |
    --------------------------------+---------------------------------------------+
    
    DATABASE CUSTOM PROPERTIES:
     +-------------------------------+--------------------------------------------+
     | NAME                          | VALUE                                      |
     +-------------------------------+--------------------------------------------+
     | strictSql                     | true                                       |
     +-------------------------------+--------------------------------------------+
    CLUSTERS (collections)
    ---------------------------------+-------+-------------------+----------------+
     NAME                            | ID    | CONFLICT STRATEGY | RECORDS        |
    ---------------------------------+-------+-------------------+----------------+
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – List Database nhận dự án làm có lương

    OrientDB – List Database



    This chapter explains how to get the list of all databases in an instance from the OrientDB command line.

    The following statement is the basic syntax of the info command.

    LIST DATABASES
    

    Note − You can use this command only after connecting to a local or remote server.

    Example

    Before retrieving the list of databases, we have to connect to the localhost server through the remote server. It is required to remind that the username and password for connecting to the localhost instance is guest and guest respectively, which is configured in the orintdb/config/orientdb-server-config.xml file.

    You can use the following command to connect to the localhost database server instance.

    orientdb> connect remote:localhost guest
    

    It will ask the password. As per the config file password for guest is also guest. If it is successfully connected, you will get the following output.

    Connecting to remote Server instance [remote:localhost] with user ''guest''...OK
    orientdb {server = remote:localhost/}>
    

    After connecting to the localhost database server you can use the following command to list the databases.

    orientdb {server = remote:localhost/}> list databases
    

    If it is successfully executed, you will get the following output −

    Found 6 databases:
    * demo (plocal)
    * s2 (plocal)
    * s1 (plocal)
    * GratefulDeadConcerts (plocal)
    * s3 (plocal)
    * sample (plocal)
    orientdb {server = remote:localhost/}>
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Config Database nhận dự án làm có lương

    OrientDB – Config Database



    In this chapter, you can learn how to display the configuration of a particular database through OrientDB command line. This command is applicable for both local and remote databases.

    Configuration information contains default cache either enabled or not, the size of that cache, the load factor value, max memory for map, node page size, pool minimum and maximum size, etc.

    The following statement is the basic syntax of the config database command.

    CONFIG
    

    Note − You can use this command only after connecting to a particular database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter.

    You can use the following command to display the configuration of demo database.

    Orientdb {db = demo}> CONFIG
    

    If it is successfully executed, you will get the following output.

    LOCAL SERVER CONFIGURATION:
    +---------------------------------------+-------------------------+
    | NAME                                  | VALUE                   |
    +---------------------------------------+-------------------------+
    | environment.dumpCfgAtStartup          | false                   |
    | environment.concurrent                | true                    |
    | environment.allowJVMShutdown          | true                    |
    | script.pool.maxSize                   | 20                      |
    | memory.useUnsafe                      | true                    |
    | memory.directMemory.safeMode          | true                    |
    | memory.directMemory.trackMode         | false                   |
    |………………………………..                         |                         |
    | storage.lowestFreeListBound           | 16                      |
    | network.binary.debug                  | false                   |
    | network.http.maxLength                | 1000000                 |
    | network.http.charset                  | utf-8                   |
    | network.http.jsonResponseError        | true                    |
    | network.http.json                     | false                   |
    | tx.log.fileType                       | classic                 |
    | tx.log.synch                          | false                   |
    | tx.autoRetry                          | 1                       |
    | client.channel.minPool                | 1                       |
    | storage.keepOpen                      | true                    |
    | cache.local.enabled                   | true                    |
    +---------------------------------------+-------------------------+
    orientdb {db = demo}>
    

    In the above list of configuration parameters, if you want to change any of the parameter value then you can do it from the command line easily using config set and get command.

    Config Set

    You can update the configuration variable value by using the CONFIG SET command.

    The following statement is the basic syntax of the config set command.

    CONFIG SET <config-variable> <config-value>
    

    Note − You can use this command only after connecting to a particular database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will modify the ‘tx.autoRetry’ variable value to 5.

    You can use the following command to set the configuration of demo database.

    orientdb {db = demo}> CONFIG SET tx.autoRetry 5
    

    If it is successfully executed, you will get the following output.

    Local configuration value changed correctly
    

    Config Get

    You can display the configuration variable value by using the CONFIG GET command.

    The following statement is the basic syntax of the config get command.

    CONFIG GET <config-variable>
    

    Note − You can use this command only after connecting to a particular database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will try to retrieve the ‘tx.autoRetry’ variable value.

    You can use the following command to display the configuration of demo database.

    orientdb {db = demo}> CONFIG GET tx.autoRetry
    

    If it is successfully executed, you will get the following output.

    Local configuration: tx.autoRetry = 5
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Freeze Database nhận dự án làm có lương

    OrientDB – Freeze Database



    Whenever you want to make the database state as static it means a state where the database didn’t respond to any of the read and write operations. Simply said, the database is in freeze state.

    In this chapter, you can learn how to freeze the database from the OrientDB command line.

    The following statement is the basic syntax of the freeze database command.

    FREEZE DATABASE
    

    Note − You can use this command only after connecting to a particular database either in remote or local database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will freeze this database from CLI.

    You can use the following command to freeze the database.

    Orientdb {db = demo}> FREEZE DATABASE
    

    If it is successfully executed, you will get the following output.

    Database ''demo'' was frozen successfully
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Export Database nhận dự án làm có lương

    OrientDB – Export Database



    Like RDBMS, OrientDB also provides features like Export and Import the database. OrientDB uses the JSON format to export the data. By default export command is using the GZIP algorithm to compress the files.

    While exporting a database it is not locking the database, which means you can perform concurrent read and write operations on it. It also means that you can create an exact copy of that data because of concurrent read and write operations.

    In this chapter, you can learn how to export the database from the OrientDB command line.

    The following statement is the basic syntax of the Export database command.

    EXPORT DATABASE <output file>
    

    Note − You can use this command only after connecting to a particular database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. You can use the following command to export the database to a file named ‘export-demo’.

    orientdb {db = demo}> EXPORT DATABASE ./export-demo.export
    

    If it is successfully executed, it will create a file named ‘export-demo.zip’ or ‘exportdemo.gz’ based on the operating system and you will get the following output.

    Exporting current database to: DATABASE /home/linuxtp/Desktop/demo.export in
    GZipped JSON format ...
    
    Started export of database ''demo'' to /home/linuxtp/Desktop/demo.export.gz...
    Exporting database info...OK
    Exporting clusters...OK (12 clusters)
    Exporting schema...OK (11 classes)
    Exporting records...
    - Cluster ''internal'' (id = 0)...OK (records = 3/3)
    - Cluster ''index'' (id = 1)...OK (records = 0/0)
    - Cluster ''manindex'' (id = 2)...OK (records = 0/0)
    - Cluster ''default'' (id = 3)...OK (records = 0/0)
    - Cluster ''orole'' (id = 4)...OK (records = 3/3)
    - Cluster ''ouser'' (id = 5)...OK (records = 3/3)
    - Cluster ''ofunction'' (id = 6)...OK (records = 0/0)
    - Cluster ''oschedule'' (id = 7)...OK (records = 0/0)
    - Cluster ''orids'' (id = 8)...OK (records = 0/0)
    - Cluster ''v'' (id = 9)...OK (records = 0/0)
    - Cluster ''e'' (id = 10)...OK (records = 0/0)
    - Cluster ''_studio'' (id = 11)...OK (records = 1/1)
    
    Done. Exported 10 of total 10 records
    
    Exporting index info...
    - Index dictionary...OK
    - Index OUser.name...OK
    - Index ORole.name...OK
    OK (3 indexes)
    Exporting manual indexes content...
    - Exporting index dictionary ...OK (entries = 0)
    OK (1 manual indexes)
    
    Database export completed in 377ms
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Release Database nhận dự án làm có lương

    OrientDB – Release Database



    In this chapter, you can learn how to release the database from the freeze state through OrientDB command line.

    The following statement is the basic syntax of the Release database command.

    RELEASE DATABASE
    

    Note − You can use this command only after connecting to a particular database, which is in freeze state.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will release the database that was freezed in the previous chapter.

    You can use the following command to release the database.

    Orientdb {db = demo}> RELEASE DATABASE
    

    If it is successfully executed, you will get the following output.

    Database ''demo'' was release successfully
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Import Database nhận dự án làm có lương

    OrientDB – Import Database



    Whenever you want to import the database, you must use the JSON format exported file, which is generated by export command.

    In this chapter you can learn how to import the database from the OrientDB command line.

    The following statement is the basic syntax of the Import database command.

    IMPORT DATABASE <input file>
    

    Note − You can use this command only after connecting to a particular database.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. You can use the following command to import the database to a file named ‘export-demo.gz’.

    orientdb {db = demo}> IMPORT DATABASE ./export-demo.export.gz
    

    If it is successfully executed, you will get the following output along with the successful notification.

    Database import completed in 11612ms
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí OrientDB – Commit Database nhận dự án làm có lương

    OrientDB – Commit Database



    Similar to RDBMS, OrientDB also provides transaction concepts like Commit and Rollback. Commit refers to closing the transaction by saving all changes to the database. Rollback refers to recovering the database state to the point where you opened the transaction.

    The following statement is the basic syntax of the Commit database command.

    COMMIT
    

    Note − You can use this command only after connecting to a particular database and after beginning the transaction.

    Example

    In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will see the operation of commit transaction and store a record using transactions.

    First, start the transaction using the following BEGIN command.

    orientdb {db = demo}> BEGIN
    

    Then, insert a record into an employee table with the values id = 12 and name = satish.P using the following command.

    orientdb> INSERT INTO employee (id, name) VALUES (12, ''satish.P'')
    

    You can use the following command to commit the transaction.

    orientdb> commit
    

    If this transaction is successfully committed, you will get the following output.

    Transaction 2 has been committed in 4ms
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc