简体   繁体   中英

OrientDB force property type to be string

I'm using OrientDB and trying to create new property after I inserted my data (millions of rows).

I'm trying to create property on V in order to create an index and I'm getting the following error:

The database contains some schema-less data in the property 'V.ACCOUNT_NO' that is not compatible with the type STRING. Fix those records and change the schema again [ONetworkProtocolHttpDb]

Now part of the fields type is INTEGER but it seems to me that it's very easy to convert the type to STRING.
how can I do it to the entire data?

I tried your case by creating this simple structure in schema-less mode:

在此输入图像描述

These records are a mix of INTEGER and STRING types:

在此输入图像描述

Now you can convert the not string records type by using this query:

UPDATE V SET ACCOUNT_NO = ACCOUNT_NO.asString() WHERE ACCOUNT_NO.type() <> 'STRING'

Output:

在此输入图像描述

About the exception, I got correctly the same error when I try to create a new property V.ACCOUNT_NO of type STRING in schema-full mode and this is correct because the property already exists in the database and contains mixed types of records, although in schema-less mode.

Once all the records were converted, you'll able to create the new property.

在此输入图像描述

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM