Console - CREATE PROPERTY
Creates a new property on the given class. The class must already exist.
Syntax
CREATE PROPERTY <class-name>.<property-name> <property-type> [<linked-type>][ <linked-class>]
<class-name>Defines the class you want to create the property in.<property-name>Defines the logical name of the property.<property-type>Defines the type of property you want to create. Several options are available:<linked-type>Defines the containter type, used in container property types.<linked-class>Defines the container class, used in container property types.
NOTE: There are several property and link types available. For more information, see Property Types.
Examples
Create the property
nameon the classUser, of the string type:orientdb>CREATE PROPERTY User.name STRINGCreate a list of strings as the property
tagsin the classProfile, using an embedded list of the string type.orientdb>CREATE PROPERTY Profile.tags EMBEDDEDLIST STRINGCreate the embedded map property
friendsin the classProfile, link it to the classProfile.orientdb>CREATE PROPERTY Profile.friends EMBEDDEDMAP ProfileThis forms a circular reference.
To remove a property, use the
DROP PROPERTYcommand. For more information, see SQL Commands and Console Commands.
Property Types
When creating properties, you need to define the property type, so that OrientDB knows the kind of data to expect in the field. There are several standard property types available:
BOOLEAN |
INTEGER |
SHORT |
LONG |
FLOAT |
DATE |
STRING |
EMBEDDED |
LINK |
BYTE |
BINARY |
DOUBLE |
In addition to these, there are several more property types that function as containers. These form lists, sets and maps. Using container property types requires that you also define a link type or class.
EMBEDDEDLIST |
EMBEDDEDSET |
EMBEDDEDMAP |
LINKLIST |
LINKSET |
LINKMAP |
Link Types
The link types available are the same as those available as the standard property types:
BOOLEAN |
INTEGER |
SHORT |
LONG |
FLOAT |
DOUBLE |
DATE |
STRING |
BINARY |
EMBEDDED |
LINK |
BYTE |