create table进阶学习系列(七)
  本篇学习create table子项:supplemental_logging_props
 
supplemental_logging_props子项组成如下: 
 
  { supplemental_log_grp_clause
   | supplemental_id_key_clause
  }
 
supplemental_log_grp_clause子句
  GROUP log_group
  (column [ NO LOG ]
           [, column [ NO LOG ] ]...)
  [ ALWAYS ]
 
 
supplemental_id_key_clause子句
DATA
({ ALL
 | PRIMARY KEY
 | UNIQUE
 | FOREIGN KEY
 }
   [, { ALL
      | PRIMARY KEY
      | UNIQUE
      | FOREIGN KEY
      }
  ]...
)
COLUMNS

先测试  supplemental_log_grp_clause子句

ALL_LOG_GROUPS
  --此视图查询当前数据库的日志组定义的相关信息
 ALL_LOG_GROUPS describes the log group definitions on the tables accessible to the current user.
 
SQL> r
  1* select log_group_name,table_name,column_name,position,logging_property from
 dba_log_group_columns
LOG_GROUP_NAME       TABLE_NAME           COLUMN_NAM   POSITION LOGGING_PROP
-------------------- -------------------- ---------- ---------- ------------
ENC$_LOG_GRP         ENC$                 OBJ#                1 LOG
ENC$_LOG_GRP         ENC$                 OWNER#              2 LOG
---如下为supplemental_logging_props语义
supplemental_logging_props
---记录额外日志为了支持基于日志的工具
The supplemental_logging_props clause lets you instruct the database to put additional data into the log stream to support log-based tools.
 
supplemental_log_grp_clause Use this clause to create a named log group.
 ?
The NO LOG clause lets you omit from the redo log one or more columns that would otherwise be included in the redo for the named log group. You must specify at least one fixed-length column without NO LOG in the named log group.
 
?
If you specify ALWAYS, then during an update, the database includes in the redo all columns in the log group. This is called an unconditional log group (sometimes called an "always log group"), because Oracle Database supplementally logs all the columns in the log group when the associated row is modified. If you omit ALWAYS, then the database supplementally logs all the columns in the log group only if any column in the log group is modified. This is called a conditional log group.
 
You can query the appropriate USER_, ALL_, or DBA_LOG_GROUP_COLUMNS data dictionary view to determine whether any supplemental logging has already been specified.

---第一种语法创建一直报错,
SQL> create table t_constraint_table(a int) group lgrp always;
create table t_constraint_table(a int) group lgrp always
                                       *
ERROR at line 1:
ORA-00922: missing or invalid option
--查询网络,采用alter table运行成功
SQL> alter table t_log add supplemental log group log_grp(a) always;
Table altered.
SQL>
---上述添加的信息已经体现出来,log_grp日志组,它用于表t_log
SQL> select log_group_name,table_name,column_name,position,logging_property from
  2   dba_log_group_columns
  3  ;
 
LOG_GROUP_NAME                 TABLE_NAME                     COLUMN_NAME                                                                        POSITION LOGGING_PROPERTY
------------------------------ ------------------------------ -------------------------------------------------------------------------------- ---------- ----------------
ENC$_LOG_GRP                   ENC$                           OBJ#                                                                                      1 LOG
ENC$_LOG_GRP                   ENC$                           OWNER#                                                                                    2 LOG
LOG_GRP                        T_LOG                          A                                                                                         1 LOG
 
--日志组信息
SQL> select * from dba_log_groups;
 
OWNER                          LOG_GROUP_NAME                 TABLE_NAME                     LOG_GROUP_TYPE      ALWAYS      GENERATED
------------------------------ ------------------------------ ------------------------------ ------------------- ----------- --------------
SYS                            ENC$_LOG_GRP                   ENC$                           USER LOG GROUP      ALWAYS      USER NAME
SCOTT                          LOG_GRP                        T_LOG                          USER LOG GROUP      ALWAYS      USER NAME
 
--删除表的附加日志记录功能 
SQL> alter table t_log drop supplemental log group log_grp;
 
Table altered 
---必须要在日志组中指定一个表列开启日志记录功能,否则报错
SQL> alter table t_log add supplemental log group log_grp (a no log) always;
 
alter table t_log add supplemental log group log_grp (a no log) always
 
ORA-32592: all columns in log group can not be no log columns
 
SQL> alter table t_log add supplemental log group log_grp (a,b no log) always;
 
Table altered

---第二种语法 supplemental_id_key_clause子句
SQL> alter table t_log add supplemental log data (all) columns;
 
Table altered
SQL> alter table t_log drop supplemental log data(all) columns;
 
Table altered
 
SQL> alter table t_log add supplemental log data (primary key) columns;
 
Table altered
 
SQL> alter table t_log drop supplemental log data(all) columns;
 
alter table t_log drop supplemental log data(all) columns
 
ORA-32587: Cannot drop nonexistent all column supplemental logging
 
SQL> alter table t_log drop supplemental log data(primary key) columns;
 
Table altered
 
SQL> alter table t_log add supplemental log data (unique) columns;
 
Table altered
 
SQL> alter table t_log drop supplemental log data(unique) columns;
 
Table altered
 
SQL> alter table t_log add supplemental log data (foreign) columns;
 
alter table t_log add supplemental log data (foreign) columns
 
ORA-00905: missing keyword
 
SQL> alter table t_log add supplemental log data (foreign key) columns;
 
Table altered
 
SQL> alter table t_log drop supplemental log data(foreign key) columns;
 
Table altered
 
SQL> alter table t_log add supplemental log data (all primary key) columns;
 
alter table t_log add supplemental log data (all primary key) columns
 
ORA-00907: missing right parenthesis
 
SQL> alter table t_log add supplemental log data (all,primary key) columns;
 
Table altered
 
SQL> alter table t_log drop supplemental log data (all,primary key) columns;
 
Table altered
---第二种语法的语义
--可指定all,primary key,unique,foreign key的单项或组合或全部
supplemental_id_key_clause Use this clause to specify that all or a combination of the primary key, unique key, and foreign key columns should be supplementally logged. Oracle Database will generate either an unconditional log group or a conditional log group. With an unconditional log group, the database supplementally logs all the columns in the log group when the associated row is modified. With a conditional log group, the database supplementally logs all the columns in the log group only if any column in the log group is modified.
---如下为各选项含义
---all columns为无条件式,由系统生成的日志组;
If you specify ALL COLUMNS, then the database includes in the redo log all the fixed-length maximum size columns of that row. Such a redo log is a system-generated unconditional log group.
 
---primary key,用于附有主键的表;一旦表更新,则记录表主键所有列相关信息
If you specify PRIMARY KEY COLUMNS, then for all tables with a primary key, the database places into the redo log all columns of the primary key whenever an update
----数据库评估记录哪些列的原则如下
is performed. Oracle Database evaluates which columns to supplementally log as follows:
--首先选取主键约束所属列(即引约束处于验证或标记不rely,且未标记为disabled或initially deferred)
First the database chooses columns of the primary key constraint, if the constraint is validated or marked RELY and is not marked as DISABLED or INITIALLY DEFERRED.
 
--如主键列不存在,数据库会选取最小的非空值且为唯一索引的列;
If no primary key columns exist, then the database looks for the smallest UNIQUE index with at least one NOT NULL column and uses the columns in that index.
 
--如上述两条件皆不满足,数据库记录表中所有的标量列
If no such index exists, then the database supplementally logs all scalar columns of the table.
 
---unique columns,面向唯一键或位图索引的列,此为有条件式的系统产生的日志组
If you specify UNIQUE COLUMNS, then for all tables with a unique key or a bitmap index, if any of the unique key or bitmap index columns are modified, the database
places into the redo log all other columns belonging to the unique key or bitmap index. Such a log group is a system-generated conditional log group.
 
--foreign key,面向外键所属表.如外键列修改,数据库则记录属于此外键的其它所有列的信息;
If you specify FOREIGN KEY COLUMNS, then for all tables with a foreign key, if any foreign key columns are modified, the database places into the redo log all
other columns belonging to the foreign key. Such a redo log is a system-generated conditional log group.
 
---如你指定多次此子句,数据库会创建多个独立的日志组
If you specify this clause multiple times, then the database creates a separate log group for each specification. You can query the appropriate USER_, ALL_,
or DBA_LOG_GROUPS data dictionary view to determine whether any supplemental logging data has already been specified.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-753074/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9240380/viewspace-753074/

create table进阶学习(四)相关推荐

  1. 第十四章 SQL命令 CREATE TABLE(一)

    文章目录 第十四章 SQL命令 CREATE TABLE(一) 大纲 参数 描述 语法概述 SQL安全和权限 表名 表存在 第十四章 SQL命令 CREATE TABLE(一) 创建表 大纲 CREA ...

  2. Mysql进阶学习(四)分组函数与分组查询

    Mysql进阶学习(四)分组函数与分组查询 一.进阶4:分组函数 1.简单的使用 1.1 SUM 求和 1.2 AVG 求平均值 1.3MIN 最小值 1.4 MAX 最大值 1.5 COUNT求总数 ...

  3. Oracle 学习笔记二 Create table

    1.创建用户 create user hfy identified by hfy; 2.在该用户下建表 建表必须满足权限和表空间: 首先连接sys账户,grant create session to ...

  4. 数据库学习 - create table(创建表)

    创建table 简单语法形式: create table 表名(列名 数据类型[primary key|unique] [not null] [,列名 数据类型[not null],...]); &q ...

  5. 一起进阶学习JAVA:MySQL海量数据存储与优化

    一起进阶学习JAVA:MySQL海量数据存储与优化 第一部分 分库分表实战及中间件 1.1 背景介绍 1.1.1 背景描述 刚开始我们的系统只用了 单机数据库 随着用户的不断增多,考虑到系统的高可用和 ...

  6. Mysql进阶学习(二)条件查询

    Mysql进阶学习(二)条件查询 进阶2:条件查询 一.按条件表达式筛选 案例1:查询工资>12000的员工信息 案例2:查询部门编号不等于90号的员工名和部门编号 二.按逻辑表达式筛选 案例1 ...

  7. Mysql进阶学习(五)连接查询(包含sql92标准和sql99标准)

    Mysql进阶学习(五)连接查询(包含sql92标准和sql99标准) 一.进阶6:连接查询 (一).sql92标准 1.等值连接 1.1 等值连接简介 案例1:查询女神名和对应的男神名 案例2:查询 ...

  8. (转)SpringMVC学习(四)——Spring、MyBatis和SpringMVC的整合

    http://blog.csdn.net/yerenyuan_pku/article/details/72231763 之前我整合了Spring和MyBatis这两个框架,不会的可以看我的文章MyBa ...

  9. Mysql进阶学习(一)基础查询

    Mysql进阶学习(一) 进阶一:基础查询 1.查询表中的单个字段 2.查询表中的多个字段 3.查询表中的所有字段 4.查询常量值 5.查询表达式 6.查询函数 7.起别名 8.去重 9.+号的作用 ...

最新文章

  1. vue中动态样式不起作用? scoped了解一下
  2. centos7 pam mysql.so,Centos7下搭建FTP服务器(博主亲测不坑)
  3. RMI远程方法调用讲解教程
  4. 查看文档(API) (NSString)
  5. android sdk 源码解析
  6. python 栈道实现
  7. 50:树中两个结点的最低公共祖先
  8. aba会导致问题_肌肤缺水会导致哪些问题呢?我们又该怎么判断呢?
  9. 华为手机如何升级鸿蒙系统_再见了安卓!华为鸿蒙系统正式上线:这几款手机可先升级...
  10. 郭台铭“炮轰”微软;腾讯应用宝全面封禁多闪;波音更新飞行软件 | 极客头条...
  11. vector中针对自定义类型的排序
  12. tp3.2 页面trace使用
  13. 深圳瑞光康泰RBP-9000C血压仪对接
  14. C. Mortal Kombat Tower(动态规划)Educational Codeforces Round 95 (Rated for Div. 2)
  15. MATLAB-真彩色图像RGB直方图绘制
  16. MATLAB 动态曲线 视频
  17. 绘图与滤镜全面解析--Quartz 2D 、Core Image
  18. 丢手帕问题(约瑟夫问题-数组实现)
  19. itx 主板支持服务器内存,华擎造了块有4条DDR4内存插槽的ITX主板出来,还板载4核CPU...
  20. t-sne算法用于处理词嵌入中的高维降维问题

热门文章

  1. 2013.12.26:4G
  2. unity性能优化-GPU
  3. 搜狗搜索:与网站权重相关的8个知识点
  4. 互联网摸鱼日报(2023-01-26)
  5. 【虚拟终端工具】SecureCRT工具连接虚拟机、rz/sz传输、中文乱码问题解决
  6. HashMap的四种遍历方法,及效率比较(简单明了)
  7. 刘二第九节,多分类问题
  8. csp计算机认证考试题,CCF数图 | 第22次CSP认证题目精讲已收录
  9. 软件测试实例-如何测试用户界面登陆过程
  10. go module无法下载golang.org/x