登录 注册
当前位置:主页 > 资源下载 > 50 > DM8_SQL语言使用手册.pdf下载

DM8_SQL语言使用手册.pdf下载

  • 更新:2024-08-24 09:58:56
  • 大小:5.26MB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:其它 - 数据库
  • 格式:PDF

资源介绍

目录 第 1 章 结构化查询语言 DM_SQL 简介 ....................................................................1 1.1 DM_SQL 语言的特点 .....................................................................................................1 1.2 保留字与标识符 ............................................................................................................2 1.3 DM_SQL 语言的功能及语句 .........................................................................................2 1.4 DM_SQL 所支持的数据类型 .........................................................................................3 1.4.1 常规数据类型 ....................................................................................................3 1.4.2 位串数据类型 ....................................................................................................5 1.4.3 日期时间数据类型 ............................................................................................6 1.4.4 多媒体数据类型 ..............................................................................................10 1.5 DM_SQL 语言支持的表达式 .......................................................................................10 1.5.1 数值表达式 ......................................................................................................11 1.5.2 字符串表达式 ..................................................................................................13 1.5.3 时间值表达式 ..................................................................................................13 1.5.4 时间间隔值表达式 ..........................................................................................15 1.5.5 运算符的优先级 ..............................................................................................16 1.6 DM_SQL 语言支持的数据库模式 ...............................................................................17 第 2 章 手册中的示例说明 ......................................................................................18 2.1 示例库说明 ..................................................................................................................18 2.2 参考脚本 ......................................................................................................................26 2.2.1 创建示例库 ......................................................................................................26 2.2.2 创建模式及表 ..................................................................................................26 2.2.3 插入数据 ..........................................................................................................33 第 3 章 数据定义语句 ..............................................................................................50 3.1 数据库修改语句 ..........................................................................................................50 3.2 管理用户 ......................................................................................................................53 3.2.1 用户定义语句 ..................................................................................................53 3.2.2 修改用户语句 ..................................................................................................59 3.2.3 用户删除语句 ..................................................................................................62 3.3 管理模式 ......................................................................................................................63 3.3.1 模式定义语句 ..................................................................................................63 3.3.2 设置当前模式语句 ..........................................................................................65 3.3.3 模式删除语句 ..................................................................................................65 3.4 管理表空间 ..................................................................................................................66 3.4.1 表空间定义语句 ..............................................................................................66 3.4.2 修改表空间语句 ..............................................................................................67 3.4.3 表空间删除语句 ..............................................................................................69 3.4.4 表空间失效文件检查 ......................................................................................70 3.4.5 表空间失效文件恢复准备 ..............................................................................70 I 目录 3.4.6 表空间失效文件恢复 ......................................................................................70 3.5 管理 HTS 表空间 .........................................................................................................71 3.5.1 创建 HTS 表空间 .............................................................................................71 3.5.2 修改 HTS 表空间 .............................................................................................71 3.5.3 删除 HTS 表空间 .............................................................................................72 3.6 管理表 ..........................................................................................................................72 3.6.1 表定义语句 ......................................................................................................72 3.6.2 表修改语句 ....................................................................................................115 3.6.3 基表删除语句 .............................................................................................133 3.6.4 基表数据删除语句 ........................................................................................134 3.6.5 事务型 HUGE 表数据重整 ............................................................................134 3.7 管理索引 ....................................................................................................................135 3.7.1 索引定义语句 ................................................................................................135 3.7.2 索引修改语句 ................................................................................................140 3.7.3 索引删除语句 ................................................................................................142 3.8 管理位图连接索引 .....................................................................................................143 3.8.1 位图连接索引定义语句 ................................................................................143 3.8.2 位图连接索引删除语句 ................................................................................145 3.9 管理全文索引 ............................................................................................................145 3.9.1 全文索引定义语句 ........................................................................................145 3.9.2 全文索引修改语句 ........................................................................................146 3.9.3 全文索引删除语句 ........................................................................................147 3.10 管理空间索引 ..........................................................................................................148 3.11 管理数组索引 ..........................................................................................................148 3.11.1 数组索引定义语句 .....................................................................................149 3.11.2 数组索引修改语句 .....................................................................................149 3.11.3 数组索引使用 .............................................................................................149 3.11.4 数组索引删除语句 .....................................................................................151 3.12 管理序列 ..................................................................................................................151 3.12.1 序列定义语句 .............................................................................................151 3.12.2 序列修改语句 .............................................................................................154 3.12.3 序列删除语句 .............................................................................................156 3.13 管理 SQL 域 .............................................................................................................156 3.13.1 创建 DOMAIN...............................................................................................156 3.13.2 使用 DOMAIN...............................................................................................157 3.13.3 删除 DOMAIN...............................................................................................158 3.14 管理上下文 ..............................................................................................................158 3.14.1 创建上下文 ..................................................................................................158 3.14.2 删除上下文 ..................................................................................................160 3.15 管理目录 ..................................................................................................................161 3.15.1 创建目录 ......................................................................................................161 3.15.2 删除目录 ......................................................................................................161 3.16 设置当前会话 ..........................................................................................................162 3.16.1 时区信息 ......................................................................................................162 II 目录 3.16.2 日期串语言 ..................................................................................................162 3.16.3 日期串格式 ..................................................................................................163 3.17 注释语句 ..................................................................................................................163 3.18 设置 INI 参数 .........................................................................................................164 3.18.1 设置参数值 ..................................................................................................164 3.18.2 设置仅对当前会话起作用 ..........................................................................165 3.19 修改系统语句 ..........................................................................................................166 3.20 设置列、索引生成统计信息 ..................................................................................166 第 4 章 数据查询语句 ............................................................................................168 4.1 单表查询 ....................................................................................................................179 4.1.1 简单查询 ........................................................................................................179 4.1.2 带条件查询 ....................................................................................................180 4.1.3 集函数 ............................................................................................................183 4.1.4 分析函数 ........................................................................................................188 4.1.5 情况表达式 ....................................................................................................205 4.2 连接查询 ....................................................................................................................209 4.2.1 交叉连接 ........................................................................................................209 4.2.2 自然连接(NATURAL JOIN)......................................................................210 4.2.3 JOIN … USING............................................................................................210 4.2.4 JOIN…ON .......................................................................................................211 4.2.5 自连接 ............................................................................................................211 4.2.6 内连接(INNER JOIN)................................................................................212 4.2.7 外连接(OUTER JOIN)................................................................................213 4.3 子查询 ........................................................................................................................217 4.3.1 标量子查询 ....................................................................................................217 4.3.2 表子查询 ........................................................................................................218 4.3.3 派生表子查询 ................................................................................................221 4.3.4 定量比较 ........................................................................................................221 4.3.5 带 EXISTS 谓词的子查询 ...........................................................................222 4.3.6 多列表子查询 ................................................................................................223 4.4 WITH 子句 ................................................................................................................224 4.4.1 WITH FUNCTION 子句 ...............................................................................224 4.4.2 公用表表达式子句 ........................................................................................225 4.5 合并查询结果 .............................................................................................................227 4.6 GROUP BY 和 HAVING 子句 ....................................................................................229 4.6.1 GROUP BY 子句的使用 ...............................................................................229 4.6.2 ROLLUP 的使用 ............................................................................................230 4.6.3 CUBE 的使用 .................................................................................................231 4.6.4 GROUPING 的使用 .......................................................................................233 4.6.5 GROUPING SETS 的使用 ...........................................................................234 4.6.6 GROUPING_ID 的使用 ................................................................................235 4.6.7 GROUP_ID 的使用 .......................................................................................236 4.6.8 HAVING 子句的使用 ....................................................................................237 III 目录 4.7 ORDER BY 子句 ........................................................................................................237 4.8 FOR UPDATE 子句 ...................................................................................................238 4.9 TOP 子句 ....................................................................................................................240 4.10 LIMIT 限定条件 .....................................................................................................241 4.10.1 LIMIT 子句 ................................................................................................241 4.10.2 ROW_LIMIT 子句 ......................................................................................242 4.11 全文检索 ..................................................................................................................243 4.12 层次查询子句 ..........................................................................................................245 4.12.1 层次查询子句 .............................................................................................245 4.12.2 层次查询相关伪列 .....................................................................................246 4.12.3 层次查询相关操作符 .................................................................................246 4.12.4 层次查询相关函数 .....................................................................................246 4.12.5 层次查询层内排序 .....................................................................................246 4.12.6 层次查询的限制 .........................................................................................247 4.13 并行查询 ..................................................................................................................251 4.14 ROWNUM ....................................................................................................................252 4.15 数组查询 ..................................................................................................................253 4.16 查看执行计划与执行跟踪统计 ..... 目录 第 7 章 物化视图 ....................................................................................................283 7.1 物化视图的定义 ....................................................................................................283 7.2 物化视图的修改 ....................................................................................................286 7.3 物化视图的删除 ....................................................................................................287 7.4 物化视图的更新 ....................................................................................................288 7.5 物化视图允许的操作 ...........................................................................................288 7.6 物化视图日志的定义 ...........................................................................................288 7.7 物化视图日志的删除 ...........................................................................................290 7.8 物化视图的限制 ....................................................................................................290 7.8.1 物化视图的一般限制 ....................................................................................290 7.8.2 物化视图的分类 ............................................................................................290 7.8.3 快速刷新通用约束 ........................................................................................291 7.8.4 物化视图信息查看 ........................................................................................291 第 8 章 函数 ............................................................................................................293 8.1 数值函数 ....................................................................................................................298 8.2 字符串函数 ................................................................................................................311 8.3 日期时间函数 ............................................................................................................332 8.4 空值判断函数 ............................................................................................................351 8.5 类型转换函数 ............................................................................................................352 8.6 杂类函数 ....................................................................................................................355 第 9 章 一致性和并发性 ........................................................................................358 9.1 DM 事务相关语句 ......................................................................................................358 9.1.1 事务的开始 ....................................................................................................358 9.1.2 事务的结束 ....................................................................................................358 9.1.3 保存点相关语句 ............................................................................................359 9.1.4 设置事务隔离级及读写特性 ........................................................................360 9.2 DM 手动上锁语句 ......................................................................................................361 第 10 章 外部函数 ..................................................................................................364 10.1 C 外部函数 ..............................................................................................................364 10.1.1 生成动态库 .................................................................................................364 10.1.2 C 外部函数创建 ..........................................................................................366 10.1.3 举例说明 .....................................................................................................367 10.2 JAVA 外部函数 .......................................................................................................369 10.2.1 生成 jar 包 ................................................................................................370 10.2.2 JAVA 外部函数创建 ..................................................................................370 10.2.3 举例说明 .....................................................................................................371 10.3 AP 使用说明 ............................................................................................................372 第 11 章 包 .............................................................................................................373 11.1 创建包 ......................................................................................................................373 V 目录 11.1.1 创建包规范 .................................................................................................373 11.1.2 创建包主体 .................................................................................................374 11.2 重编译包 ..................................................................................................................376 11.3 删除包 ......................................................................................................................376 11.3.1 删除包规范 .................................................................................................376 11.3.2 删除包主体 .................................................................................................377 11.4 应用实例 ..................................................................................................................377 第 12 章 类类型 ......................................................................................................381 12.1 普通 CLASS 类型 .....................................................................................................381 12.1.1 声明类 .........................................................................................................382 12.1.2 实现类 .........................................................................................................383 12.1.3 重编译类 .....................................................................................................385 12.1.4 删除类 .........................................................................................................386 12.1.5 类的使用 .....................................................................................................386 12.2 JAVA CLASS 类型 .................................................................................................388 12.2.1 定义 JAVA 类 ..............................................................................................389 12.2.2 重编译 JAVA 类 ..........................................................................................391 12.2.3 删除 JAVA 类 ..............................................................................................391 12.2.4 类的使用 .....................................................................................................391 第 13 章自定义类型 ................................................................................................393 13.1 创建类型 ..................................................................................................................393 13.2 创建类型体 ...............................................................................................................394 13.3 重编译类型 ...............................................................................................................395 13.4 删除类型 ...................................................................................................................395 13.4.1 删除类型 ......................................................................................................396 13.4.2 删除类型体 ..................................................................................................396 13.5 自定义类型的使用 ...................................................................................................396 13.5.1 使用规则 .....................................................................................................396 13.5.2 应用实例 .....................................................................................................396 第 14 章 触发器 ......................................................................................................398 14.1 触发器的定义 ..........................................................................................................398 14.1.1 表触发器 ......................................................................................................398 14.1.2 事件触发器 ..................................................................................................408 14.1.3 时间触发器 ..................................................................................................418 14.2 触发器替换 ..............................................................................................................419 14.3 设计触发器的原则 ...................................................................................................419 14.4 触发器的删除 ..........................................................................................................420 14.5 禁止和允许触发器 ..................................................................................................420 14.6 触发器的重编 ..........................................................................................................421 14.7 触发器应用举例 ......................................................................................................421 14.7.1 使用触发器实现审计功能 .........................................................................422 VI 目录 14.7.2 使用触发器维护数据完整性 ......................................................................422 14.7.3 使用触发器保障数据安全性 ......................................................................423 14.7.4 使用触发器生成字段默认值 ......................................................................424 第 15 章 同义词 ......................................................................................................426 15.1 创建同义词 ..............................................................................................................426 15.2 删除同义词 ..............................................................................................................427 第 16 章 外部链接 ..................................................................................................429 16.1 创建外部链接 ..........................................................................................................429 16.2 删除外部链接 ..........................................................................................................433 16.3 使用外部链接 ..........................................................................................................434 第 17 章 闪回查询 ..................................................................................................435 17.1 闪回查询子句 ..........................................................................................................435 17.2 闪回版本查询 ..........................................................................................................437 17.3 闪回事务查询 ..........................................................................................................439 第 18 章 JSON.........................................................................................................440 18.1 数据类型 ...................................................................................................................440 18.1.1 string......................................................................................................440 18.1.2 number......................................................................................................441 18.1.3 true、false...........................................................................................441 18.1.4 null...........................................................................................................443 18.1.5 object......................................................................................................444 18.1.6 array ........................................................................................................444 18.2 函数 ..........................................................................................................................444 18.2.1 json_value ............................................................................................444 18.2.2 json_query ............................................................................................445 18.2.3 函数参数详解 ...........................................................................................446 18.3 使用 IS JSON/IS NOT JSON 条件 ...................................................................448 18.4 视图 ...........................................................................................................................451 18.4.1 视图使用说明 ..............................................................................................451 18.4.2 DBA_JSON_COLUMNS................................................................................451 18.4.3 USER_JSON_COLUMNS .............................................................................452 18.4.4 ALL_JSON_COLUMNS................................................................................452 18.5 一个简单的例子 .......................................................................................................452 第 19 章 高级日志 ..................................................................................................455 19.1 简介 ..........................................................................................................................455 19.2 使用须知 ..................................................................................................................455 19.3 语法 ..........................................................................................................................455 19.3.1 管理日志辅助表 .........................................................................................455 19.3.2 使用日志辅助表的规则与约束 ..................................................................456 VII 目录 19.3.3 日志辅助表结构 .........................................................................................456 19.3.4 系统过程 .....................................................................................................457 19.4 使用高级日志同步数据的原则 ..............................................................................457 19.5 应用实例 ..................................................................................................................459 19.5.1 创建不带主键的源表 .................................................................................459 19.5.2 创建带主键的源表 .....................................................................................462 附录 1 关键字和保留字 .........................................................................................465 附录 2 SQL 语法描述说明 ....................................................................................469 附录 3 系统存储过程和函数 .................................................................................472 1) INI 参数管理 ..............................................................................................................472 2) 系统信息管理 ...............................................................................................................477 3) 备份恢复管理 ...............................................................................................................491 4) 定时器管理 ...................................................................................................................521 5) 数据复制管理 ...............................................................................................................524 6) 模式对象相关信息管理 ...............................................................................................533 7) 数据守护管理 ...............................................................................................................543 8) MPP 管理 ......................................................................................................................548 9) 日志与检查点管理 .......................................................................................................551 10) 数据库重演 ................................................................................................................552 11) 统计信息 ....................................................................................................................553 12) 资源监测 ....................................................................................................................560 13) 类型别名 ....................................................................................................................570 14) 杂类函数 ....................................................................................................................572 15) 编目函数调用的系统函数 .........................................................................................583 16) BFILE.........................................................................................................................593 17) HUGE 表备份还原 ......................................................................................................593 18) 定制会话级 INI 参数 ...............................................................................................595 19) 为 SQL 指定 HINT......................................................................................................597 20) 时区设置 ....................................................................................................................599