- OrientDB Tutorial
- OrientDB - Home
- OrientDB - Overview
- OrientDB - Installation
- OrientDB - Basic Concepts
- OrientDB - Data Types
- OrientDB - Console Modes
- OrientDB Database Commands
- OrientDB - Create Database
- OrientDB - Alter Database
- OrientDB - Backup Database
- OrientDB - Restore Database
- OrientDB - Connect Database
- OrientDB - Disconnect Database
- OrientDB - Info Database
- OrientDB - List Database
- OrientDB - Freeze Database
- OrientDB - Release Database
- OrientDB - Config Database
- OrientDB - Export Database
- OrientDB - Import Database
- OrientDB - Commit Database
- OrientDB - Rollback Database
- OrientDB - Optimize Database
- OrientDB - Drop Database
- OrientDB Record Commands
- OrientDB - Insert Record
- OrientDB - Display Records
- OrientDB - Load Record
- OrientDB - Reload Record
- OrientDB - Export Record
- OrientDB - Update Record
- OrientDB - Truncate Record
- OrientDB - Delete Record
- OrientDB Class Commands
- OrientDB - Create Class
- OrientDB - Alter Class
- OrientDB - Truncate Class
- OrientDB - Drop Class
- OrientDB Cluster Commands
- OrientDB - Create Cluster
- OrientDB - Alter Cluster
- OrientDB - Truncate Cluster
- OrientDB - Drop Cluster
- OrientDB Property Commands
- OrientDB - Create Property
- OrientDB - Alter Property
- OrientDB - Drop Property
- OrientDB Vertex Commands
- OrientDB - Create Vertex
- OrientDB - Move Vertex
- OrientDB - Delete Vertex
- OrientDB Edge Commands
- OrientDB - Create Edge
- OrientDB - Update Edge
- OrientDB - Delete Edge
- OrientDB Advanced Concepts
- OrientDB - Functions
- OrientDB - Sequences
- OrientDB - Indexes
- OrientDB - Transactions
- OrientDB - Hooks
- OrientDB - Caching
- OrientDB - Logging
- OrientDB - Performance Tuning
- OrientDB - Upgrading
- OrientDB - Security
- OrientDB - Studio
- OrientDB Interfaces
- OrientDB - Java Interface
- OrientDB - Python Interface
- OrientDB Useful Resources
- OrientDB - Quick Guide
- OrientDB - Useful Resources
- OrientDB - Discussion
OrientDB - Alter Property
Alter Property is a command used to modify or update the Property of a particular class. Altering the property means modifying the fields of a table. In this chapter, you can learn how to update the property.
The following statement is the basic syntax of Alter Property Command.
ALTER PROPERTY <class>.<property> <attribute-name> <attribute-value>
Following are the details about the options in the above syntax.
<class> − Defines the class to which the property belongs.
<property> − Defines the property you want to update.
<attribute-name> − Defines the attribute of a property you want to update.
<attribute-value> − Defines the value you want to set on the attribute.
The following table defines the list of attributes to alter the property.
Attribute | Type | Description |
---|---|---|
LINKEDCLASS | String | Defines the linked class name. Use NULL to remove an existing value. |
LINKEDTYPE | String | Defines the link type. Use NULL to remove an existing value. |
MIN | Integer | Defines the minimum value as a constraint. Use NULL to remove an existing constraint. |
MANDATORY | Boolean | Defines whether the property requires a value. |
MAX | Integer | Defines the maximum value as a constraint. Use NULL to remove an existing constraint. |
NAME | String | Defines the property name. |
NOTNULL | Boolean | Defines whether the property can have a NULL value. |
REGEX | String | Defines a Regular Expression as constraint. Use NULL to remove an existing constraint. |
TYPE | String | Defines a property type. |
COLLATE | String | Sets collate to one of the defined comparison strategies. By default, it is set to case-sensitive (cs). You can also set it to case-insensitive (ci). |
READONLY | Boolean | Defines whether the property value is immutable. That is, if it is possible to change it after the first assignment. Use with DEFAULT to have immutable values on creation. |
CUSTOM | String | Defines custom properties. The syntax for custom properties is <custom-name> = <custom-value>, such as stereotype = icon. |
DEFAULT | Defines the default value or function. |
Note − if you are altering NAME or TYPE, this command will take some time to update depending on the amount of data.
Example
Try some queries which are given below to understand Alter property.
Execute the following query to change the name of the property from ‘age’ to ‘born’ in the class Customer.
orinetdb {db = demo}> ALTER PROPERTY Customer.age NAME born
If the above query is executed successfully, you will get the following output.
Property altered successfully
Execute the following query to make ‘name’ as the mandatory property of the class ‘Customer’.
orientdb {db = demo}> ALTER PROPERTY Customer.name MANDATORY TRUE
If the above query is executed successfully, you will get the following output.
Property altered successfully