
- OrientDB 教程
- OrientDB - 首頁
- OrientDB - 概述
- OrientDB - 安裝
- OrientDB - 基本概念
- OrientDB - 資料型別
- OrientDB - 控制檯模式
- OrientDB 資料庫命令
- OrientDB - 建立資料庫
- OrientDB - 修改資料庫
- OrientDB - 備份資料庫
- OrientDB - 恢復資料庫
- OrientDB - 連線資料庫
- OrientDB - 斷開資料庫連線
- OrientDB - 資料庫資訊
- OrientDB - 列出資料庫
- OrientDB - 凍結資料庫
- OrientDB - 釋放資料庫
- OrientDB - 配置資料庫
- OrientDB - 匯出資料庫
- OrientDB - 匯入資料庫
- OrientDB - 提交資料庫
- OrientDB - 回滾資料庫
- OrientDB - 最佳化資料庫
- OrientDB - 刪除資料庫
- OrientDB 記錄命令
- OrientDB - 插入記錄
- OrientDB - 顯示記錄
- OrientDB - 載入記錄
- OrientDB - 重新載入記錄
- OrientDB - 匯出記錄
- OrientDB - 更新記錄
- OrientDB - 截斷記錄
- OrientDB - 刪除記錄
- OrientDB 類命令
- OrientDB - 建立類
- OrientDB - 修改類
- OrientDB - 截斷類
- OrientDB - 刪除類
- OrientDB 叢集命令
- OrientDB - 建立叢集
- OrientDB - 修改叢集
- OrientDB - 截斷叢集
- OrientDB - 刪除叢集
- OrientDB 屬性命令
- OrientDB - 建立屬性
- OrientDB - 修改屬性
- OrientDB - 刪除屬性
- OrientDB 頂點命令
- OrientDB - 建立頂點
- OrientDB - 移動頂點
- OrientDB - 刪除頂點
- OrientDB 邊命令
- OrientDB - 建立邊
- OrientDB - 更新邊
- OrientDB - 刪除邊
- OrientDB 高階概念
- OrientDB - 函式
- OrientDB - 序列
- OrientDB - 索引
- OrientDB - 事務
- OrientDB - 鉤子
- OrientDB - 快取
- OrientDB - 日誌記錄
- OrientDB - 效能調優
- OrientDB - 升級
- OrientDB - 安全
- OrientDB - Studio
- OrientDB 介面
- OrientDB - Java 介面
- OrientDB - Python 介面
- OrientDB 有用資源
- OrientDB - 快速指南
- OrientDB - 有用資源
- OrientDB - 討論
OrientDB - 更新記錄
更新記錄命令用於修改特定記錄的值。SET 是更新特定欄位值的命令。
以下語句是 Update 命令的基本語法。
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>]
以下是關於上述語法中選項的詳細資訊。
SET - 定義要更新的欄位。
INCREMENT - 將指定欄位的值增加給定值。
ADD - 在集合欄位中新增新項。
REMOVE - 從集合欄位中刪除一個項。
PUT - 將一個條目放入對映欄位中。
CONTENT - 用 JSON 文件內容替換記錄內容。
MERGE - 將記錄內容與 JSON 文件合併。
LOCK - 指定如何在載入和更新之間鎖定記錄。我們有兩個選項可以指定預設和記錄。
UPSERT - 如果記錄存在則更新,如果不存在則插入新記錄。它有助於在一個查詢中執行兩個查詢的操作。
RETURN - 指定要返回的表示式,而不是記錄數。
LIMIT - 定義要更新的最大記錄數。
TIMEOUT - 定義在更新超時前允許執行的時間。
示例
讓我們考慮我們在上一章中使用的相同 Customer 表格。
序號 | 姓名 | 年齡 |
---|---|---|
1 | Satish | 25 |
2 | Krishna | 26 |
3 | Kiran | 29 |
4 | Javeed | 21 |
5 | Raja | 29 |
嘗試以下查詢更新客戶“Raja”的年齡。
Orientdb {db = demo}> UPDATE Customer SET age = 28 WHERE name = 'Raja'
如果上述查詢成功執行,您將獲得以下輸出。
Updated 1 record(s) in 0.008000 sec(s).
要檢查 Customer 表格的記錄,您可以使用以下查詢。
orientdb {db = demo}> SELECT FROM Customer
如果上述查詢成功執行,您將獲得以下輸出。
----+-----+--------+----+-------+---- # |@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 ----+-----+--------+----+-------+----
廣告