[20170728]oracle保留字.txt

--//oracle有许多保留字,我印象最深的就是使用rman备份表空间test,test就是rman里面的保留字.
--//还有rman也是rman里面的保留字.如果在应用中尽量规避不要使用这些保留字.

--//探究一下,oracle内部是否也会不小心这些关键字.

1.环境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.1.0.1.0     Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0

SCOTT@test01p> @ desc v$reserved_words ;
Name       Null?    Type
---------- -------- ----------------------------
KEYWORD             VARCHAR2(30)
LENGTH              NUMBER
RESERVED            VARCHAR2(1)
RES_TYPE            VARCHAR2(1)
RES_ATTR            VARCHAR2(1)
RES_SEMI            VARCHAR2(1)
DUPLICATE           VARCHAR2(1)
CON_ID              NUMBER

SCOTT@test01p> select * from v$reserved_words where KEYWORD='TEST' or keyword='RMAN';
KEYWORD                            LENGTH R R R R D     CON_ID
------------------------------ ---------- - - - - - ----------
TEST                                    4 N N N N N          0

2.查询看看:
SELECT distinct owner,table_name
  FROM dba_tab_columns
 WHERE column_name IN (SELECT KEYWORD FROM v$reserved_words);

--//输出太多,忽略.没有想到如此之多,还是我查询有问题.找其中一个视图V$RECOVER_FILE.

SELECT  owner,table_name,column_name
  FROM dba_tab_columns
 WHERE column_name IN (SELECT KEYWORD FROM v$reserved_words) and table_name ='V_$RECOVER_FILE';

OWNER TABLE_NAME      COLUMN_NAME
----- --------------- --------------------
SYS   V_$RECOVER_FILE ONLINE
SYS   V_$RECOVER_FILE ERROR
SYS   V_$RECOVER_FILE TIME
SYS   V_$RECOVER_FILE CON_ID
--//有4个字段.

--//官方链接:http://docs.oracle.com/cd/B28359_01/server.111/b28320/dynviews_2126.htm#REFRN30204
V$RESERVED_WORDS

V$RESERVED_WORDS displays a list of all SQL keywords. To determine whether a particular keyword is reserved in any way,
check the RESERVED, RES_TYPE, RES_ATTR, and RES_SEMI columns.

Column     Datatype        Description
KEYWORD    VARCHAR2(30)    Name of the keyword
LENGTH     NUMBER          Length of the keyword
RESERVED   VARCHAR2(1)     Indicates whether the keyword cannot be used as an identifier (Y) or whether the keyword is
                           not reserved (N)
RES_TYPE   VARCHAR2(1)     Indicates whether the keyword cannot be used as a type name (Y) or whether the keyword is not
                           reserved (N)
RES_ATTR   VARCHAR2(1)     Indicates whether the keyword cannot be used as an attribute name (Y) or whether the keyword
                           is not reserved (N)
RES_SEMI   VARCHAR2(1)     Indicates whether the keyword is not allowed as an identifier in certain situations, such as
                           in DML (Y) or whether the keyword is not reserved (N)
DUPLICATE  VARCHAR2(1)     Indicates whether the keyword is a duplicate of another keyword (Y) or whether the keyword is
                           not a duplicate (N)

SELECT *
  FROM v$reserved_words
 WHERE keyword IN ('ONLINE', 'ERROR', 'TIME', 'CON_ID');

KEYWORD LENGTH R R R R D     CON_ID
------- ------- - - - - - ----------
CON_ID       6 N N N N N          0
ERROR        5 N N N N N          0
TIME         4 N N N N N          0
ONLINE       6 N N N Y N          0

SCOTT@test01p> select * from V$RECOVER_FILE;
no rows selected

SCOTT@test01p> select file#,ONLINE,ERROR, TIME,CON_ID from V$RECOVER_FILE;
select file#,ONLINE,ERROR, TIME,CON_ID from V$RECOVER_FILE
             *
ERROR at line 1:
ORA-00936: missing expression

D:\tools\rlwrap>oerr ora 00936
00936, 00000, "missing expression"
// *Cause:
// *Action:

--//出现这个提示非常具有迷惑性,不过要特别注意下面的星号的位置,指向ONLINE.
--//规避它使用双引号,并且注意要大写:

SCOTT@test01p> select file#,"ONLINE",ERROR, TIME,CON_ID from V$RECOVER_FILE;
no rows selected
--//其他字段没问题,除了ONLINE字段.

SCOTT@test01p> select file#,"online",ERROR, TIME,CON_ID from V$RECOVER_FILE;
select file#,"online",ERROR, TIME,CON_ID from V$RECOVER_FILE
             *
ERROR at line 1:
ORA-00904: "online": invalid identifier

SCOTT@test01p> alter database datafile 9 offline;
Database altered.

SCOTT@test01p> select file#,"online",ERROR, TIME,CON_ID from V$RECOVER_FILE;
select file#,"online",ERROR, TIME,CON_ID from V$RECOVER_FILE
             *
ERROR at line 1:
ORA-00904: "online": invalid identifier

SCOTT@test01p> select file#,"ONLINE",ERROR, TIME,CON_ID from V$RECOVER_FILE;
     FILE# ONLINE  ERROR   TIME                    CON_ID
---------- ------- ------- ------------------- ----------
         9 OFFLINE         2017-07-27 21:01:22          3

SCOTT@test01p> recover datafile 9;
Media recovery complete.

SCOTT@test01p> alter database datafile 9 online;
Database altered.

总之:
--//在应用中尽量规避这些保留字,避免不必要的麻烦!!
--//在11g下再补充一些例子:

SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> alter tablespace tea rename to test;
Tablespace altered.

RMAN> backup tablespace test ;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "test": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 19 file: standard input

SCOTT@book> alter tablespace test rename to rman;
Tablespace altered.

RMAN> backup tablespace rman ;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "rman": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 19 file: standard input

SCOTT@book> alter tablespace rman rename to tea;
Tablespace altered.

RMAN> backup tablespace tea;
Starting backup at 2017-07-28 08:42:12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=94 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=106 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=119 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
channel ORA_DISK_1: starting piece 1 at 2017-07-28 08:42:14
channel ORA_DISK_1: finished piece 1 at 2017-07-28 08:42:15
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2017_07_28/o1_mf_nnndf_TAG20170728T084214_dqo2364j_.bkp tag=TAG20170728T084214 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2017-07-28 08:42:15
Starting Control File and SPFILE Autobackup at 2017-07-28 08:42:15
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_07_28/o1_mf_s_950517735_dqo23786_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-07-28 08:42:16

--//在sqlplus的命令中不是的关键字的test,rman,到了rman命令变成了关键字.

[20170728]oracle保留字.txt的更多相关文章

  1. [20171214]hashcat破解oracle口令.txt

    [20171214]hashcat破解oracle口令.txt hashcat is the world's fastest and most advanced password recovery u ...

  2. [20171213]john破解oracle口令.txt

    [20171213]john破解oracle口令.txt --//跟别人讨论的oracle破解问题,我曾经提过不要使用6位字符以下的密码,其实不管那种系统低于6位口令非常容易破解.--//而且orac ...

  3. oracle导入TXT文件

    oracle导入TXT文件: 1.建好对应的表和字段:2.新建test.ctl文件,用记事本编辑写入: OPTIONS (skip) load data INFILE 'E:\8080.txt' -- ...

  4. oracle 导入txt

    没有Oraclehoume的情况下,执行下环境变量文件 sqlldr userid= DM/DM control = /home/oracle/libc/load.ctl load data infi ...

  5. Oracle中的Spool缓冲池技术可以实现Oracle导出txt格式文件

    利用Oracle中的Spool缓冲池技术可以实现Oracle数据导出到文本文件 1.在Oracle PL/SQL中输入缓冲开始命令,并指定输出的文件名: spool d:output.txt; 2.设 ...

  6. Oracle导出txt文本文件

    转自: http://blog.csdn.net/ahngzw77/article/details/8652722 对于SPOOL数据的SQL,最好要自己定义格式,以方便程序直接导入,SQL语句如:  ...

  7. oracle 写入txt

    分几个步骤 1,创建输出路径,比如你要在/orcl/dir目录下输出,你就先要建立好这个路径,并在root用户下 chmod 777 /orcl/dir 2,sqlplus下以sysdba登录,执行以 ...

  8. shell实现查询oracle数据库表,并写到本地txt文件

    1.表结构 create table t_student( id ) primary key, name ), birthday date ); increment ; insert into t_s ...

  9. 使用sqlldr向Oracle导入大的文本(txt)文件

    我们有多种方法可以向Oracle数据库里导入文本文件,但如果导入的文本文件过大,例如5G,10G的文本文件,有些方法就不尽如意了,例如PLSQL Developer中的导入文本功能,如果文本文件过大, ...

随机推荐

  1. IO流查找文件然后写入TXT文档

    今天领导让分析日志,把日志中所有登录过的员工信息都拿出来.于是.把日志摘下来谢了这段代码 import java.io.BufferedReader;import java.io.BufferedWr ...

  2. Python编码和Unicode

    原文链接: ERIC MORITZ   翻译: 伯乐在线- 贱圣OMG译文链接: http://blog.jobbole.com/50345/ 我确定有很多关于Unicode和Python的说明,但为 ...

  3. TkMyBatis大杂烩

    1. 什么是TkMyBatis TkMyBatis是一个MyBatis的通用Mapper工具 2. 引入TkMyBatis到SpringBoot项目 以Gradle为例 compile 'tk.myb ...

  4. Spring Boot + Spring Cloud 构建微服务系统(八):分布式链路追踪(Sleuth、Zipkin)

    技术背景 在微服务架构中,随着业务发展,系统拆分导致系统调用链路愈发复杂,一个看似简单的前端请求可能最终需要调用很多次后端服务才能完成,那么当整个请求出现问题时,我们很难得知到底是哪个服务出了问题导致 ...

  5. shiro源码篇 - shiro的session的查询、刷新、过期与删除,你值得拥有

    前言 开心一刻 老公酷爱网络游戏,老婆无奈,只得告诫他:你玩就玩了,但是千万不可以在游戏里找老婆,不然,哼哼... 老公嘴角露出了微笑:放心吧亲爱的,我绝对不会在游戏里找老婆的!因为我有老公! 老婆: ...

  6. 分布式版本控制系统GIT的使用

    一.什么是Git Git是一个分布式版本控制系统,Git 和其他版本控制系统的主要差别在于,Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件内容的具体差异(如CVS.Subver ...

  7. Ubuntu下将现有的文件打包成deb包

    转自:http://www.linuxidc.com/Linux/2008-04/12297.htm deb是Debian Linux的软件包格式.一般来说是需要通过编译源码然后制作deb包,今天由于 ...

  8. windows server 证书的颁发与IIS证书的使用

    最近工作业务要是用服务器证书验证,在这里记录下一. 1.添加服务器角色 [证书服务] 2.一路下一步直到证书服务安装完成; 3.选择圈选中的服务器证书 4.点击[创建证书申请] 5.填写信息 6.下一 ...

  9. angularjs学习第八天笔记(指令作用域研究)

    您好,在前两天对指令的简单了解和系统指令学习后 今天主要研究其指针作用域的相关事情 每一个指令在创建时,其实就构成了自己的一个小的模块单元. 其对于的模块单元都有着其对于的作用域,其中作用域一般有两种 ...

  10. T-SQL:排除阻塞(十六)

    当一个事务持有事务的资源锁,并且另一个事务请求同一资源的不兼容锁时,请求被阻塞并且请求者进入等待状态,直到锁定者释放干扰锁. 长时间运行事务会导致锁被长时间持有,所以只对要开启事务的表操作代码开启事务 ...