当前位置: 首页 > news >正文

[20170728]oracle保留字.txt

[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命令变成了关键字.

转载于:https://www.cnblogs.com/lfree/p/7273063.html

相关文章:

  • 为何我们要用 React 来写小程序 - Taro 诞生记
  • 漫步云端:谁给你的安全买单?
  • 深度学习最佳实践系列——权重w初始化
  • 《大数据原理:复杂信息的准备、共享和分析》一一2.10 重标识
  • Html引入百度富文本编辑器ueditor
  • 中国AI研究超美国?专家:比如深度学习已发文章数
  • linux查看服务安装目录
  • OpenStack云吸引十六巨头 致力于实现LAMP互操作负载共享
  • [Android开源]EasySharedPreferences:优雅的进行SharedPreferences数据存储操作
  • github上fork别人的代码之后,如何保持和原作者同步的更新
  • 026 UI调试
  • Spring框架心得笔记
  • 筛法求素数模板
  • 通过创建脚本代替scrapy crawl Test命令
  • Linux系统运维常见面试简答题系列(二)(14题)
  • 「面试题」如何实现一个圣杯布局?
  • 【每日笔记】【Go学习笔记】2019-01-10 codis proxy处理流程
  • 2017-09-12 前端日报
  • android高仿小视频、应用锁、3种存储库、QQ小红点动画、仿支付宝图表等源码...
  • C++回声服务器_9-epoll边缘触发模式版本服务器
  • canvas绘制圆角头像
  • CSS3 变换
  • js递归,无限分级树形折叠菜单
  • k8s 面向应用开发者的基础命令
  • Nginx 通过 Lua + Redis 实现动态封禁 IP
  • node-sass 安装卡在 node scripts/install.js 解决办法
  • Twitter赢在开放,三年创造奇迹
  • vue和cordova项目整合打包,并实现vue调用android的相机的demo
  • 短视频宝贝=慢?阿里巴巴工程师这样秒开短视频
  • 力扣(LeetCode)21
  • 前言-如何学习区块链
  • 世界编程语言排行榜2008年06月(ActionScript 挺进20强)
  • 云栖大讲堂Java基础入门(三)- 阿里巴巴Java开发手册介绍
  • 测评:对于写作的人来说,Markdown是你最好的朋友 ...
  • ​虚拟化系列介绍(十)
  • #100天计划# 2013年9月29日
  • #我与Java虚拟机的故事#连载03:面试过的百度,滴滴,快手都问了这些问题
  • (C#)Windows Shell 外壳编程系列9 - QueryInfo 扩展提示
  • (DenseNet)Densely Connected Convolutional Networks--Gao Huang
  • (html转换)StringEscapeUtils类的转义与反转义方法
  • (pojstep1.1.2)2654(直叙式模拟)
  • (Redis使用系列) Springboot 在redis中使用BloomFilter布隆过滤器机制 六
  • (ZT) 理解系统底层的概念是多么重要(by趋势科技邹飞)
  • (八)Spring源码解析:Spring MVC
  • (附源码)ssm高校运动会管理系统 毕业设计 020419
  • (原+转)Ubuntu16.04软件中心闪退及wifi消失
  • (转)Oracle 9i 数据库设计指引全集(1)
  • (转)人的集合论——移山之道
  • (转)为C# Windows服务添加安装程序
  • * CIL library *(* CIL module *) : error LNK2005: _DllMain@12 already defined in mfcs120u.lib(dllmodu
  • 、写入Shellcode到注册表上线
  • .NET大文件上传知识整理
  • // an array of int
  • [20171113]修改表结构删除列相关问题4.txt
  • [CTF]php is_numeric绕过