Update Record order is utilized to change the estimation of a specific record. SET is the essential order to refresh a specific field esteem.
The accompanying assertion is the essential linguistic structure of the Update order.
UPDATE <class>|cluster:<cluster>|<recordID>
[SET|INCREMENT|ADD|REMOVE|PUT <field-name> = <field-value>[,]*] |[CONTENT| MERGE <JSON>]
[UPSERT]
[RETURN <returning> [<returning-expression>]]
[WHERE <conditions>]
[LOCK default|record]
[LIMIT <max-records>] [TIMEOUT <timeout>]
Following are the insights concerning the alternatives in the above language structure.
- SET − Defines the field to refresh.
- Addition − Increments the predetermined field an incentive by the given worth.
- ADD − Adds the new thing in the assortment fields.
- Eliminate − Removes a thing from the assortment field.
- PUT − Puts a section into map field.
- CONTENT − Replaces the record content with JSON archive content.
- Consolidation − Merges the record content with a JSON report.
- LOCK − Specifies how to bolt the records among burden and update. We have two choices to indicate Default and Record.
- UPSERT − Updates a record on the off chance that it exists or embeds another record on the off chance that it doesn't. It helps in executing a solitary inquiry in the spot of executing two inquiries.
- RETURN − Specifies an articulation to return rather than the quantity of records.
- Cutoff − Defines the greatest number of records to refresh.
- Break − Defines the time you need to permit the update run before it times out.
Example
Allow us to consider a similar Customer table that we have utilized in the past section.
Sr.No. | Name | Age |
---|---|---|
1 | Satish | 25 |
2 | Krishna | 26 |
3 | Kiran | 29 |
4 | Javeed | 21 |
5 | Raja | 29 |
Attempt the accompanying inquiry to refresh the age of a client 'Raja'.
Orientdb {db = demo}> UPDATE Customer SET age = 28 WHERE name = 'Raja'
In the event that the above inquiry is executed effectively, you will get the accompanying yield.
?Updated 1 record(s) in 0.008000 sec(s).
To check the record of Customer table you can utilize the accompanying question.
orientdb {db = demo}> SELECT FROM Customer
In the event that the above inquiry is executed effectively, you will get the accompanying yield.
----+-----+--------+----+-------+----
# |@RID |@CLASS |id |name |age
----+-----+--------+----+-------+----
0 |#11:0|Customer|1 |satish |25
1 |#11:1|Customer|2 |krishna|26
2 |#11:2|Customer|3 |kiran |29
3 |#11:3|Customer|4 |javeed |21
4 |#11:4|Customer|5 |raja |28
----+-----+--------+----+-------+----