[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

[20170728]oracle保留字.txt相关推荐

  1. oracle批量替换保留字,常见的oracle保留字

    常见的oracle保留字有这些: ACCESS ADD ALL ALTER AND ANY AS ASC AUDIT BETWEEN BY CHAR CHECK CLUSTER COLUMN COMM ...

  2. oracle 导txt,oracle 导入txt

    1899800 广东省东莞市 电信 0769 1899801 广东省东莞市 电信 0769 如上,有25w条手机号归属地的记录要入库,文件是excel格式的 首先,建表,4个字段: 然后,将excel ...

  3. ORACLE导入TXT文件数据的解决思路

    需求场景: data.txt源数据: [INFO] 2012-12-01 00:01:17 1610 FHR "行号=24. 查看指定计划的钢卷数据. 计划号=121200102." ...

  4. oracle打开 txt文件,oracle 导入txt文件

    第一次接触Oracle,记录一下导入txt文件的过程. 首先,导入txt文件需要格式上整齐,类似下图: 然后Oracle创建表: create table OUTCLINICAL2DIM( MPI_P ...

  5. Oracle 导入 txt (oracle 10) 百万数据导入 txt

    索引 1.1.1,Oracle 百万数据导入 txt 1.1.2,准备工作 1.1.3,首先我们创建个测试账户 #1.1.4,写个测试表 1.1.5,编写自动入库脚本 ctl 1.1.6,示例1 编写 ...

  6. oracle批量替换保留字,oracle保留字大全

    1.    ALL和ANY的比较 any的例子: select * from t_hq_ryxx wheregongz > any (select pingjgz from t_hq_bm); ...

  7. oracle数据库导入txt,oracle数据库导入TXT文件方法介绍

    客户端连接数据库导入 1. 安装有oracle客户端,配好监听. 2. 以oracle数据库app用户的表user_svc_info为例 CREATE TABLE USER_SVC_INFO( PHO ...

  8. oracle 外部表加载txt文件-导入银行信息-ok

    0.将windows上文件的格式从UTF-16转为utf-8 [root@Cloud-Server ~]# file 111111.txt 111111.txt: Little-endian UTF- ...

  9. Oracle通过SPOOL导出数据Excel、CSV、TXT格式

    文章目录 1. SPOOL基础 2. SPOOL使用示例 3. 简化SPOOL导出的一个小(偷懒)脚本   <从来不需要解释 那些所谓奇怪的事 你是上天的恩赐 因为珍惜学会坚持--> 1. ...

最新文章

  1. python语言入门z-【python】编程语言入门经典100例--22
  2. SQL--Chapter1_Overview of SQL Server
  3. Exercise 42: Is-A, Has-A, Objects, and Classes
  4. android扫码支付宝ofo,六大共享单车接入支付宝 ofo等免押金扫一扫可骑走
  5. Cloud for Customer的前端如何判断自己是运行在PC浏览器还是移动设备里
  6. spark基础之RDD详解
  7. 微软欲打造开发者联盟!
  8. 开源阅读书源_安卓神器 | 开源小说软件阅读3.0,附赠大量书源
  9. n步自举法:时序差分方法与蒙特卡洛方法的结合
  10. 蓝桥杯单片机组经验分享之(三)各模块用法(1)138译码器
  11. 408 操作系统 知识点总结
  12. 给你一个二维整数数组 matrix,返回 matrix 的 转置矩阵
  13. 蚂蚁森林公益合种带我种“大树”
  14. 京准通-全店海投出价方式介绍
  15. sql server 函數
  16. 用胶带屏蔽PCIE接口解决兼容问题,150块的P104矿渣卡也能跑深度学习
  17. 商务签证的准备(1)
  18. NUCLEO-L432KC实现GPIO控制(STM32L432KC)
  19. 邵阳市计算机学校某灿,最近喜欢上一首歌。。 大家把自己觉得好听的歌和我分享分享吧。...
  20. linux docker安装nginx且测试elasticsearch分词

热门文章

  1. 通过Scroller.js制作上拉加载和下拉刷新
  2. DHCP的安装与分配
  3. android 连接服务器
  4. 伍哥原创之豆荚商城商品搜索架构介绍
  5. jquery实现开关灯
  6. 关于从基于Mult-Org的视图中查询数据的问题(转)
  7. 小试“ASUS WL-500W无线路由”
  8. “习惯性思维”引起的血案
  9. 策略路由实验,指定出口
  10. Spring-----projects-----概述