在DB2數(shù)據(jù)庫的表中插入和刪除數(shù)據(jù)
在DB2數(shù)據(jù)庫中創(chuàng)建了存儲數(shù)據(jù)的表之后,需要能夠?qū)?shù)據(jù)移入或移出表。將數(shù)據(jù)放入表中最簡單的方法是使用INSERT命令。為了插入數(shù)據(jù),要提供想插入數(shù)據(jù)的表和列以及數(shù)據(jù)本身。在插入數(shù)據(jù)之后,就可以選擇、更新或刪除它。
這個練習(xí)演示如何將數(shù)據(jù)移入或移出數(shù)據(jù)庫。
在Control Center Object視圖中,選擇數(shù)據(jù)庫列表中的AUTHOR表并點(diǎn)擊Open。
如下圖所示,點(diǎn)擊 Add Row。將數(shù)據(jù)輸入列中并提交事務(wù)。
如果沒有出現(xiàn)錯誤,就沒有反饋。點(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)擊其他行并刪除它以清空這個表,然后點(diǎn)擊Close。
相關(guān)文章:
1. DB2的高可用性和災(zāi)難恢復(fù)概述2. navicat for mysql創(chuàng)建數(shù)據(jù)庫的方法3. Oracle數(shù)據(jù)庫中臨時表的進(jìn)一步深入研究4. 用一個案例講解SQL Server數(shù)據(jù)庫恢復(fù)5. 使用DB2look重新創(chuàng)建優(yōu)化器訪問計(jì)劃(4)6. IBM DB2 Connect簡介(1)7. 如何在oracle中導(dǎo)入dmp數(shù)據(jù)庫文件8. DB2 XML 全文搜索之為文本搜索做準(zhǔn)備9. 標(biāo)準(zhǔn)MySQL數(shù)據(jù)庫外的5個開源兼容方案10. 大表delete刪數(shù)據(jù)導(dǎo)致數(shù)據(jù)庫異常解決
