文档详情

吉林大学数据库技术与Oracle sql-08.ppt

发布:2025-06-11约1.15万字共42页下载文档
文本预览下载声明

ManipulatingData

ObjectivesAftercompletingthislesson,youshouldbeabletodothefollowing:DescribeeachDMLstatementInsertrowsintoatableUpdaterowsinatableDeleterowsfromatableMergerowsinatableControltransactions

DataManipulationLanguageADMLstatementisexecutedwhenyou:AddnewrowstoatableModifyexistingrowsinatableRemoveexistingrowsfromatableAtransactionconsistsofacollectionofDMLstatementsthatformalogicalunitofwork.

AddingaNewRowtoaTableDEPARTMENTSNewrow…insertanewrowintotheDEPARMENTStable…

TheINSERTStatementSyntaxAddnewrowstoatablebyusingtheINSERTstatement.

Onlyonerowisinsertedatatimewiththissyntax.INSERTINTO table[(column[,column...])]VALUES (value[,value...]);

InsertingNewRowsInsertanewrowcontainingvaluesforeachcolumn.Listvaluesinthedefaultorderofthecolumnsinthetable.Optionally,listthecolumnsintheINSERTclause.

Enclosecharacteranddatevalueswithinsinglequotationmarks.INSERTINTOdepartments(department_id,department_name,manager_id,location_id)VALUES(70,PublicRelations,100,1700);1rowcreated.

INSERTINTO departmentsVALUES (100,Finance,NULL,NULL);1rowcreated.INSERTINTO departments(department_id,department_name)VALUES (30,Purchasing);1rowcreated.InsertingRowsWithNullValuesImplicitmethod:Omitthecolumnfromthe

columnlist.Explicitmethod:SpecifytheNULLkeywordintheVALUESclause.

INSERTINTOemployees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,commission_pct,manager_id,department_id)VALUES (113,Louis,Popp,LPOPP,515.124.4567,SYSDATE,AC_ACCOUNT,6900,NULL,205,100);1rowcreated.InsertingSpecialValuesTheSYSDATEfunctionrecordsthe

显示全部
相似文档