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 class Account to born:

    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 unique id that cannot be changed after creation:

    orientdb> ALTER PROPERTY Client.id DEFAULT "uuid()" READONLY
    orientdb> ALTER PROPERTY Client.id READONLY TRUE
    

Supported Attributes

AttributeTypeSupportDescription
LINKEDCLASSStringDefines the linked class name. Use NULL to remove an existing value.
LINKEDTYPEStringDefines the link type. Use NULL to remove an existing value.
MINIntegerDefines 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.
MANDATORYBooleanDefines whether the property requires a value.
MAXIntegerDefines 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.
NAMEStringDefines the property name.
NOTNULLBooleanDefines whether the property can have a null value.
REGEXPStringDefines a Regular Expression as constraint. Use NULL to remove an existing constraint.
TYPEStringDefines a property type.
COLLATEStringSets 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).
READONLYBooleanDefines 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.
CUSTOMStringDefines custom properties. The syntax for custom properties is <custom-name> = <custom-value>, such as stereotype = icon. The custom name is an identifier, so it has to be back-tick quoted if it contains special characters (eg. dots); the value is a string, so it has to be quoted with single or double quotes.
DEFAULTDefines the default value or function. Feature introduced in version 2.1, (see the section above for examples). Use NULL to remove an existing constraint.

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. When altering property name, the old value is copied to the new property name.

To create a property, use the CREATE PROPERTY command, to remove a property the DROP PROPERTY command.
For more information on other commands, please refer to Console Commands and SQL Commands.