Example 5.21.1 Recall the table EMPHIST introduced in Example 3.3.5. A script to create and populate the tables discussed in that example is contained in the script ced.sql that is available in Appendix C.
To give all current employees a 10% raise, we apply the following update phrase:
update EMPHIST
set salary = 1.1* salary where term_date is null;
The general syntax of update is: update table name [corr name]
set column = hexpression|nulli {,column = hexpression|nulli}
[wherecondition]
The insert construct adds new rows to a table. It inserts a single rows (whose components must be specified by the user) or a set of rows that originate from a retrieval involving other tables.
The syntax of a single-tuple insert is:
insert into table name[(column{, column}] hvalues(expr {, expr})|subselecti
The values of expressions listed in the list of values must belong to the domains of the attributes specified in the list of columns in order for the insertion to take effect.
Example 5.21.2 To insert two rows containing registration records for stu- dent 2890 for the fall semester of 2004 into GRADES, we execute two insert statements:
insert into GRADES
values (’2890’,’023’,’cs110’,’Fall’,2004,null); insert into GRADES
values (’2890’,’056’,’cs240’,’Fall’,94,null);
ตัวอย่าง 5.21.1 เรียกคืนตาราง EMPHIST ที่นำมาใช้ในตัวอย่างที่ 3.3.5 สคริปต์เพื่อสร้าง และเติมข้อมูลตารางในตัวอย่างที่มีอยู่ใน ced.sql สคริปต์ที่มีอยู่ในภาคผนวกคเพื่อให้พนักงานทั้งหมดปัจจุบันเพิ่ม 10% เราใช้วลีปรับปรุงต่อไปนี้:อัพเด EMPHISTตั้งเงินเดือน =เงินเดือน 1.1* ที่ term_date เป็น nullไวยากรณ์ทั่วไปของการปรับปรุง: ปรับปรุงตารางชื่อ [ชื่อคอรร์]ตั้งค่าคอลัมน์ = hexpression|nulli {, คอลัมน์ = hexpression|nulli }[wherecondition]สร้างแทรกเพิ่มแถวใหม่ลงในตาราง แทรกแถวเดียวที่ (ที่มีส่วนประกอบต้องเป็น specified โดยผู้ใช้) หรือชุดของแถวที่มาจากการเรียกที่เกี่ยวข้องกับตารางอื่นไวยากรณ์ของแทรกทูเพิลเดียวคือ:ใส่ลงในตารางชื่อ [(คอลัมน์ { คอลัมน์}] hvalues (expr { expr }) |subselectiค่าของนิพจน์ที่แสดงในรายการของค่าที่ต้องเป็นสมาชิกของโดเมนของ specified แอตทริบิวต์ในรายการของคอลัมน์การแทรกจะ effectตัวอย่าง 5.21.2 การแทรกแถวที่สองประกอบด้วยเรกคอร์ดการลงทะเบียนสำหรับ stu-เด็นท์ 2890 สำหรับภาคฤดูใบไม้ร่วงของปี 2004 ในเกรด เราดำเนินคำสั่ง insert ที่สอง:ใส่เกรดค่า ('2890', '023', 'cs110' ตก' 2004, null); ใส่เกรดค่า ('2890', '056', 'cs240' 'ตก' 94, null);
การแปล กรุณารอสักครู่..

ตัวอย่าง 5.21.1 จำ EMPHIST ตารางนำมาใช้ในตัวอย่าง 3.3.5 สคริปต์เพื่อสร้างและเติมตารางที่กล่าวถึงในตัวอย่างที่มีอยู่ใน ced.sql สคริปต์ที่มีอยู่ในภาคผนวกคเพื่อให้พนักงานทั้งหมดในปัจจุบันเพิ่มขึ้น 10% เราใช้วลีปรับปรุงต่อไปนี้: การปรับปรุง EMPHIST ชุดเงินเดือน = 1.1 * เงินเดือนที่ term_date เป็นโมฆะ; ไวยากรณ์ทั่วไปของการปรับปรุงคือชื่อตารางการปรับปรุง [ชื่อ Corr] คอลัมน์ตั้ง = hexpression | ไอ {คอลัมน์ = hexpression | ไอ} [WhereCondition] สร้างแทรกเพิ่มแถวใหม่ในตาราง มันแทรกแถวเดียว (ซึ่งเป็นส่วนประกอบจะต้องเป็นเอ็ดที่ระบุโดยผู้ใช้) หรือชุดของแถวที่มาจากการดึงที่เกี่ยวข้องกับตารางอื่น ๆ . ไวยากรณ์ของแทรกเดียว tuple คือใส่ลงในชื่อตาราง [(คอลัมน์ {คอลัมน์} ] hvalues (expr {, expr}) | subselecti ค่าของการแสดงออกที่ระบุไว้ในรายการค่าต้องเป็นสมาชิกของโดเมนของคุณลักษณะเอ็ดที่ระบุไว้ในรายการของคอลัมน์ในการสั่งซื้อสำหรับการแทรกที่จะใช้อี ff ect. ตัวอย่าง 5.21.2 การแทรก สองแถวที่มีการบันทึกการลงทะเบียนสำหรับบุ๋ม stu- 2890 สำหรับภาคการศึกษาฤดูใบไม้ร่วงของปี 2004 เข้าสู่การเรียนเราดำเนินการสองงบแทรก: แทรกลงในการเรียนค่า ('2890', '023', 'cs110', 'ฤดูใบไม้ร่วง', 2004, null) ; แทรกลงในการเรียนค่า ('2890', '056', 'cs240', 'ฤดูใบไม้ร่วง', 94, null);
การแปล กรุณารอสักครู่..
