SQL - ALTER PROPERTY
Updates attributes on the existing property and class in the schema.
Syntax
ALTER PROPERTY <class>.<property> <attribute-name> <attribute-value>
<class>
Defines the class to which the property belongs.<property>
Defines the property you want to update.<attribute-name>
Defines the attribute you want to change.<attribute-value>
Defines the value you want to set on the attribute.
Examples
Change the name of the property
age
in the classAccount
toborn
:orientdb>
ALTER PROPERTY Account.age NAME born
Update a property to make it mandatory:
orientdb>
ALTER PROPERTY Account.age MANDATORY TRUE
Define a Regular Expression as constraint:
orientdb>
ALTER PROPERTY Account.gender REGEXP "[M|F]"
Define a field as case-insensitive to comparisons:
orientdb>
ALTER PROPERTY Employee.name COLLATE ci
Define a custom field on a property:
orientdb>
ALTER PROPERTY Foo.bar1 custom stereotype = visible
Set the default value for the current date:
orientdb>
ALTER PROPERTY Client.created DEFAULT sysdate()
Define a unqiue id that cannot be changed after creation:
orientdb>
ALTER PROPERTY Client.id DEFAULT uuid() READONLY
orientdb>ALTER PROPERTY Client.id READONLY TRUE
Supported Attributes
Attribute | Type | Support | 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. On String attributes, it defines the minimum length of the string. On Integer attributes, it defines the minimum value for the number. On Date attributes, the earliest date accepted. For multi-value attributes (lists, sets and maps), it defines the fewest number of entries. |
|
MANDATORY |
Boolean | Defines whether the proprety requires a value. | |
MAX |
Integer | Defines the maximum value as a constraint. Use NULL to remove an existing constraint. On String attributes, it defines the greatest length of the string. On Integer attributes, it defines the maximum value for the number. On Date attributes, the last date accepted. For multi-value attributes (lists, sets and maps), it defines the highest number of entries. |
|
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. Feature introduced in version 2.1, (see the section above for examples). |
When altering NAME
or TYPE
this command runs a data update that may take some time, depending on the amount of data. Don't shut the database down during this migration.
To create a property, use the
CREATE PROPERTY
command, to remove a property theDROP PROPERTY
command. For more information on other commands, see Console and SQL commands.