Chapter 09-Manipulating Data - 01
2013-04-16 22:54
351 查看
Objectives
After completing this lesson,you should be able to do the following:Describe each data manipulation language(DML) statement.
Insert rows into a table.
Update rows in a table.
Delete rows from a table.
Control transactions.
Lesson Agenda
Adding new rows in a table-INSERT statement
Changing data in a table
-UPDATE statement
Removing rows from a table:
-DELETE statement
-TRUNCATE statement
Database transactions control using COMMIT,ROLLBACK,and SAVEPOINT
Read consistency
FOR UPDATE clause in a SELECT statement
Data Manipulatioin Language
A DML statement is executed when you:-Add new rows to a table
-Modify existing rows in a table
-Remove existing rows from a table
A transaction consists of a collection of DML statements that form a logical unit of work.
Adding a New Row to a table
very simple to do , you knowINSERT Statement Syntax
Add new rows to a table by using the INSERT statementINSERT INTO table [(column,[,column...])] VALUES (value [,value...]);
With this syntax,only one row is inserted at a time.
INSERT New Rows
Insert a new row containing values for each column.List values in the default order of the columns in the table.
Optionally,list the columns in the INSERT clause.
INSERT INTO departments(department_id,department_name,manager_id,location_id) VALUES(70,'Public Relations',100,1700);
Enclose character and date values within single quotation marks.
Build a Lab Environment
Copy Data From Another TableSQL> INSERT INTO DEPT SELECT * FROM departments; 27 rows created. SQL> SELECT * FROM DEPT; DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID ------------- ------------------------------ ---------- ----------- 10 Administration 200 1700 20 Marketing 201 1800 30 Purchasing 114 1700 40 Human Resources 203 2400 50 Shipping 121 1500 60 IT 103 1400 70 Public Relations 204 2700 80 Sales 145 2500 90 Executive 100 1700 100 Finance 108 1700 110 Accounting 205 1700 DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID ------------- ------------------------------ ---------- ----------- 120 Treasury 1700 130 Corporate Tax 1700 140 Control And Credit 1700 150 Shareholder Services 1700 160 Benefits 1700 170 Manufacturing 1700 180 Construction 1700 190 Contracting 1700 200 Operations 1700 210 IT Support 1700 220 NOC 1700 DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID ------------- ------------------------------ ---------- ----------- 230 IT Helpdesk 1700 240 Government Sales 1700 250 Retail Sales 1700 260 Recruiting 1700 270 Payroll 1700 27 rows selected.
相关文章推荐
- [bbk2341] 第46集 - Chapter 09-Optimizing Sore Perations(01)
- [bbk2191] 第32集 - Chapter 09-Optimizing Sore Perations(01)
- Chapter -09 Creating Procedures 01
- chapter 01 -Main
- 【Cocos2d-x3.0学习笔记 09】游戏实例跑跑跑01
- 17 - 01 - 09 POJ 1363 (栈模拟)
- Tornado框架09-异步01
- 01_09.常见文本样式
- Chapter 09-Manipulation Data - 02
- Chapter -03 Writing Executable Statements 01
- [bbk2342] 第47集 - Chapter 09-Optimizing Sore Perations(02)
- [bbk2864] 第55集 - Chapter 14-Using Oracle Dasta Storage Structures Efficiently(01)
- Chapter 4-01
- 11 01 09 不安的星期天
- Chapter 6-01
- Chapter 01 - Background to T-SQL Querying and Programming
- 2011 -09-01-实现递归列目录的操作
- APUE读书笔记-09进程关系(01)
- 06/01/09
- 09_注解01