oracle 12c 学习

Posted 刚好遇见Mysql

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 12c 学习相关的知识,希望对你有一定的参考价值。

1、不可见字段

SQL> create table ht (a number,b varchar2(20) invisible);

Table created.

SQL> desc ht;
 Name					   Null?    Type
 ----------------------------------------- -------- ----------------------------
 A						    NUMBER

SQL> set colinvisible on
SQL> desc ht;
 Name					   Null?    Type
 ----------------------------------------- -------- ----------------------------
 A						    NUMBER
 B (INVISIBLE)					    VARCHAR2(20)

SQL> insert into ht values(1,‘beijing‘);
insert into ht values(1,‘beijing‘)
            *
ERROR at line 1:
ORA-00913: too many values
SQL> insert into ht (a,b) values(1,‘beijing‘);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from ht;

	 A
----------
	 1

SQL> select a,b from ht;

	 A B
---------- --------------------
	 1 beijing

SQL> insert into ht1 values(1,‘beijing‘);

1 row created.

  不可见字段的表可以强制开发人员select 语句时指定字段不能用*代替,和普通表对比起来 插入数据时必须指定字段加大拉开发的代码量。

2、在同一列上创建不同功能索引

SQL> create index idx_ht_b1 on ht(b);  

Index created.

SQL> create index idx_ht_b2 on ht(upper(b));

Index created.

3、ddl 语句日志记录

SQL> show parameter enable_ddl_logging;

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging		     boolean	 TRUE

SQL> create table ht2 as select * from ht1;

Table created.

SQL> drop table ht2 purge;

Table dropped.

[qdtais]@ht02[/u01/app/db/diag/rdbms/qdtais/qdtais/log/ddl]$tail -10 log.xml 
 <txt>create table ht2 as select * from ht1
 </txt>
</msg>
<msg time=‘2019-12-05T18:27:42.271-05:00‘ org_id=‘oracle‘ comp_id=‘rdbms‘
 msg_id=‘opiexe:4850:2946163730‘ type=‘UNKNOWN‘ group=‘diag_adl‘
 level=‘16‘ host_id=‘ht02‘ host_addr=‘fe80::f9f1:ad02:b6a6:ea2f%enp0s3‘
 pid=‘4338‘>
 <txt>drop table ht2 purge
 </txt>
</msg>

4、dba保护增强--备份可以分配权限

SQL> grant sysbackup to ht;

Grant succeeded.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[qdtais]@ht02[/home/oracle]$rman target ht/ht

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Dec 5 18:36:46 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: QDTAIS (DBID=1154019395)

RMAN> 

5、expdp/impdp 增强

impdp 避免产生大量日志
TRANSFORM
Metadata transform to apply to applicable objects.
Valid keywords are: DISABLE_ARCHIVE_LOGGING, INMEMORY, INMEMORY_CLAUSE,
LOB_STORAGE, OID, PCTSPACE, SEGMENT_ATTRIBUTES, SEGMENT_CREATION,
STORAGE, and TABLE_COMPRESSION_CLAUSE.

expdp时把视图转化为表
VIEWS_AS_TABLES
Identifies one or more views to be exported as tables.
For example, VIEWS_AS_TABLES=HR.EMP_DETAILS_VIEW

6、varchar2  nvarchar2 数据字段长度扩大到32K,11g以前只有4K,存大文本时避免使用 clob blob,数据库需要重启。

SQL> show parameter max_string_size;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
max_string_size string STANDARD

SQL> ALTER SYSTEM SET max_string_size=extended SCOPE=SPFILE;

System altered.

SQL> startup upgrade
ORACLE instance started.

Total System Global Area 1644163728 bytes
Fixed Size 8897168 bytes
Variable Size 637534208 bytes
Database Buffers 989855744 bytes
Redo Buffers 7876608 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utl32k.sql

7、 在线移动并重命名数据文件,move数据文件时不影响用户ddl、dml,可以把omf文件转化为正常文件,也可以直接move到asm磁盘组

    FILE# NAME
---------- --------------------------------------------------------------------------------
	 1 /u01/app/db/oradata/QDTAIS/system01.dbf
	 3 /u01/app/db/oradata/QDTAIS/sysaux01.dbf
	 4 /u01/app/db/oradata/QDTAIS/undotbs01.dbf
	 5 /u01/app/db/oradata/QDTAIS/datafile/o1_mf_ht_gym38cqq_.dbf
	 7 /u01/app/db/oradata/QDTAIS/users01.dbf

SQL> alter database move datafile 5 to ‘/home/oracle/o1_mf_ht_gym38cqq_.dbf‘;
alter database move datafile 5 to ‘/home/oracle/o1_mf_ht_gym38cqq_.dbf‘
*
ERROR at line 1:
ORA-01276: Cannot add file /home/oracle/o1_mf_ht_gym38cqq_.dbf.  File has an Oracle Managed Files file name.

SQL> alter database move datafile 5 to ‘/home/oracle/*‘;

Database altered.

SQL> alter database move datafile 5 to ‘/u01/app/db/oradata/QDTAIS/ht01.dbf‘;

Database altered.

SQL> select file#,name from v$datafile;

     FILE# NAME
---------- --------------------------------------------------------------------------------
	 1 /u01/app/db/oradata/QDTAIS/system01.dbf
	 3 /u01/app/db/oradata/QDTAIS/sysaux01.dbf
	 4 /home/oracle/undotbs01.dbf
	 5 /u01/app/db/oradata/QDTAIS/ht01.dbf
	 7 /u01/app/db/oradata/QDTAIS/users01.dbf

8、高级索引压缩及表压缩,以前这些特性只在oracle亲儿子exadata上使用

SQL> SELECT table_name, compression, compress_for FROM user_tables;
 
TABLE_NAME       COMPRESSION   COMPRESS_FOR
---------------- ------------  -----------------
T1               DISABLED
T2               ENABLED       BASIC
T3               ENABLED       ADVANCED
T4               ENABLED       QUERY HIGH
T5               ENABLED       ARCHIVE LOW

  

 

 

以上是关于oracle 12c 学习的主要内容,如果未能解决你的问题,请参考以下文章

学习笔记:Oracle 12C 数据非常规恢复工具bbed的使用说明

vmware安装oracle 12c rac内存一般设多大

Oracle 数据库12c 16大新特性总结

Oracle 数据库12c 16大新特性总结

《Oracle 12c 运维实战宝典》-安装视频

用于 oracle 12c 和 oracle 19c 中的引用游标的 Jooq 代码生成类