在DB2數(shù)據(jù)庫的表中插入和刪除數(shù)據(jù)
在DB2數(shù)據(jù)庫中創(chuàng)建了存儲(chǔ)數(shù)據(jù)的表之后,需要能夠?qū)?shù)據(jù)移入或移出表。將數(shù)據(jù)放入表中最簡單的方法是使用INSERT命令。為了插入數(shù)據(jù),要提供想插入數(shù)據(jù)的表和列以及數(shù)據(jù)本身。在插入數(shù)據(jù)之后,就可以選擇、更新或刪除它。
這個(gè)練習(xí)演示如何將數(shù)據(jù)移入或移出數(shù)據(jù)庫。
在Control Center Object視圖中,選擇數(shù)據(jù)庫列表中的AUTHOR表并點(diǎn)擊Open。
如下圖所示,點(diǎn)擊 Add Row。將數(shù)據(jù)輸入列中并提交事務(wù)。
如果沒有出現(xiàn)錯(cuò)誤,就沒有反饋。點(diǎn)擊Close關(guān)閉Open Table窗口。
通過Tools > Command Editor打開Command Editor。手工輸入INSERT命令,包括連接數(shù)據(jù)庫的語句:
connect to hellowld; insert into hwld.author values ('Claire', 1, 'DB2 UDB', '<author_info> <name>Claire</name> <ID>1</ID> <department> <department_title>DB2 CE</department_title> <responsibility>Supporting customer problems</responsibility> <start_year>2005</start_year> </department> <department> <department_title>DB2 Index Manager</department_title> <responsibility>Develop new features for DB2 indexes</responsibility> <start_year/> </department> </author_info>', 100); terminate;
(還可以使用命令編輯視圖執(zhí)行同樣的操作。)
點(diǎn)擊綠色的三角圖標(biāo)運(yùn)行命令。圖3顯示預(yù)期的運(yùn)行結(jié)果:
如果表中有不再需要的數(shù)據(jù),可以使用同樣的窗口刪除它。點(diǎn)擊表AUTHOR和Open。
選擇第一行并點(diǎn)擊Delete Row。點(diǎn)擊Commit提交刪除操作。如果決定中止刪除操作,那么點(diǎn)擊Roll Back而不是Commit。
點(diǎn)擊其他行并刪除它以清空這個(gè)表,然后點(diǎn)擊Close。
相關(guān)文章:
1. DB2的高可用性和災(zāi)難恢復(fù)概述2. golang中連接mysql數(shù)據(jù)庫3. 關(guān)于DB2數(shù)據(jù)庫的系統(tǒng)信息集成(1)4. 記一次mariadb數(shù)據(jù)庫無法連接5. SQL Server 數(shù)據(jù)庫中的收縮數(shù)據(jù)庫和文件操作6. SQL Server備份數(shù)據(jù)庫的完整步驟7. SQLite3數(shù)據(jù)庫的介紹和使用教程(面向業(yè)務(wù)編程-數(shù)據(jù)庫)8. 如何修改Linux服務(wù)器中的MySQL數(shù)據(jù)庫密碼9. DB2 V9.5工作負(fù)載管理之閾值(THRESHOLD)10. 教你在IBM DB2數(shù)據(jù)庫中進(jìn)行包的重綁定
