在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. Access數(shù)據(jù)庫日常維護(hù)方法(優(yōu)化)2. 數(shù)據(jù)庫相關(guān)的幾個(gè)技能:ACCESS轉(zhuǎn)SQL3. 巧用SQL語言在ACCESS數(shù)據(jù)庫中批量替換內(nèi)容4. 如何實(shí)現(xiàn)MySQL數(shù)據(jù)庫的備份與恢復(fù)5. Mysql入門系列:安排預(yù)防性的維護(hù)MYSQL數(shù)據(jù)庫服務(wù)器6. DB2 常用命令小結(jié)7. Access數(shù)據(jù)庫提示OleDbException (0x80004005): 操作必須使用一個(gè)可更新的查詢8. DB2中多種常用功能的解決方法(1)9. MySQL刪除數(shù)據(jù)庫表的操作方法10. DB2如何提高IMPORT命令的性能

網(wǎng)公網(wǎng)安備