文档详情

《Oracle数据库-- ddl和dml语句扩展 chinese》.ppt

发布:2015-10-19约1.87万字共21页下载文档
文本预览下载声明
Oracle9i 对 DML 和 DDL 语句的扩展 目标 通过本章学习,您将可以: 描述多表插入的特点 使用不同类型的多表插入 无条件的INSERT 旋转 INSERT 有条件的 ALL INSERT 有条件的 FIRST INSERT 创建和使用外部表 创建主键约束的同时创建索引 INSERT 语句 使用 INSERT 语句向表中插入新的数据 使用上面的语句每次只能向表中插入一行数据 UPDATE 语句 使用UPDATE 语句更新表中的数据 使用上面的语句每次可更新表中的一行或多行数据 使用 WHERE 子句指定更新的条件 多表 INSERT 语句 INSERT...SELECT 是使用一个DML 语句向多个表中插入数据的一部分 多表INSERT 语句可作为数据仓库应用中向目标数据库传送数据的一种方法 它具有更高的效率: 避免使用多各DML 语句 使用一个DML 完成 IF...THEN 的逻辑处理 多表 INSERT 语句的类型 Oracle9i 提供以下四种多表INSERT 语句类型: 无条件的 INSERT 有条件的 ALL INSERT 有条件的 FIRST INSERT 旋转 INSERT 多表 INSERT 语句 无条件的 INSERT ALL 应用举例 有条件的 INSERT ALL 应用举例 有条件的 FIRST INSERT 应用举例 旋转 INSERT 应用举例 外部表 外部表是只读的表,其数据存储在数据库外的平面文件中 外部表的各种参数在 CREATE TABLE 语句中指定 使用外部表, 数据可以存储到外部文件或从外部文件中上载数据到数据库 数据可以使用 SQL访问, 但不能使用 DML 后在外部表上创建索引 创建路径 创建外部表之前应先使用CREATE DIRECTORY语句创建路径 创建外部表举例 查询外部表 创建主键约束同时创建索引举例 总结 通过本章学习,您已经可以: 使用多表插入代替多个单独的 DML 语句 创建外部表 创建主键约束同时创建索引 Conditional FIRST INSERT (continued) The example in the slide inserts rows into more than one table, using one single INSERT statement. The SELECT statement retrieves the details of department ID, total salary, and maximum hire date for every department in the EMPLOYEES table. This INSERT statement is referred to as a conditional FIRST INSERT, as an exception is made for the departments whose total salary is more than $25,000. The condition WHEN ALL 25000 is evaluated first. If the total salary for a department is more than $25,000, then the record is inserted into the SPECIAL_SAL table irrespective of the hire date. If this first WHEN clause evaluates to true, the Oracle Server executes the corresponding INTO clause and skips subsequent WHEN clauses for this row. For the rows that do not satisfy the first WHEN condition (WHEN SAL 25000), the rest of the conditions are evaluated just as a conditional INSERT statement, and the records retrieved by the SELECT statement are inserted into the HIREDATE_HISTORY_00, or HIREDATE_HISTORY_99, or HIREDATE_HISTORY tables, based on the value in the HIREDATE column. The
显示全部
相似文档