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

时间: 2024-08-24 13:28:04

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

[20171213]john破解oracle口令.txt

[20171213]john破解oracle口令.txt --//跟别人讨论的oracle破解问题,我曾经提过不要使用6位字符以下的密码,其实不管那种系统低于6位口令非常容易破解. --//而且oracle缺省还保证旧口令模式在sys.user$文件中,破解这个更容易.我仅仅写一些例子: 1.环境: SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------

[20130218]快速安装oracle数据库.txt

[20130218]快速安装oracle数据库.txt 快速安装windows的例子:(windows的环境没有测试过) windows下执行:dbca -Silent  -createDatabase -gdbName test -templateName %oracle_home%\assistants\dbca\templates\General_Purpose.dbc -characterSet ZHS16GBK  -nationalCharacterSet AL16UTF16 -dat

[20171214]hashcat破解oracle口令.txt

[20171214]hashcat破解oracle口令.txt hashcat is the world's fastest and most advanced password recovery utility, supporting five unique modes of attack for over 200 highly-optimized hashing algorithms. hashcat currently supports CPUs, GPUs, and other hard

批处理写的oracle数据库备份还原工具

由于平时要进行数据库的备份和还原操作,为了提高效率和节省时间就有了下面的批处理程序.这是针对oracle编写的,可以用在不同的电脑上,因为它会自动读取当前电脑的环境变量,从而取得oracle的安装路径,唯一有一点不足的地方是程序中运行过程中会产生一个中间文本文件,不过这并不碍大事,备份或者还原完了以后将会自动删除产生文本文件,代码如下: @echo off&setlocal enabledelayedexpansion color 0a :start for /f "tokens=2 d

Oracle 10g 11g 单机环境的安装

Oracle 10g 11g 单机环境的安装 前提条件要准备2台测试用的机器,开始制作如下:+要保证2台机器安装oracle10g以及更高的版本,我这里是用的10.2.0.5做实验. 准备工具: Xmanager4   Xftp工具.Xsell工具.Window DOS控制台.Redhat6.1操作系统.Oracle10.2.0.1 安装包 .升级包.补丁包.   1 安装操作系统 我的实验环境是 redhat6.1 2台 以最小化安装的. 2  安装操作系统: Linux redhat6.1 

批处理写的 oracle 数据库备份还原工具_DOS/BAT

这是针对oracle编写的,可以用在不同的电脑上,因为它会自动读取当前电脑的环境变量,从而取得oracle的安装路径,唯一有一点不足的地方是程序中运行过程中会产生一个中间文本文件,不过这并不碍大事,备份或者还原完了以后将会自动删除产生文本文件,代码如下: 复制代码 代码如下: @echo off&setlocal enabledelayedexpansion color 0a :start for /f "tokens=2 delims==" %%a in ('path') d

Oracle 控制文件(CONTROLFILE)

--============================= -- Oracle 控制文件(CONTROLFILE) --=============================   一.Oracle 控制文件         为二进制文件,初始化大小由CREATE DATABASE指定,可以使用RMAN备份         记录了当前数据库的结构信息,同时也包含数据文件及日志文件的信息以及相关的状态,归档信息等等         在参数文件中描述其位置,个数等等.通常采用分散放开,多路复用

《Oracle达人修炼秘籍:Oracle 11g数据库管理与开发指南 》一3.3 安装Oracle 11g数据库服务器

3.3 安装Oracle 11g数据库服务器 Oracle Universal Installer(OUI)是基于Java技术的图形界面安装工具,利用它可以很方便地在不同操作系统平台上完成对不同类型的.不同版本的Oracle软件的安装. 1)右击setup.exe文件,在弹出菜单中选择"以管理员身份运行",启动OUI.OUI先根据install\oraparam.int文件中的参数设置情况进行系统软.硬件的先决条件检查,并输出检查结果,如图3-9所示.注意 在Windows 7操作系统

1229Create schema synonym in Oracle 12c

[20141229]Create schema synonym in Oracle 12c.txt 链接: http://www.dbi-services.com/index.php/blog/entry/create-schema-synonym-in-oracle-unsupported-feature --如果我们查看12c的cataudit.sql文件,可以发现如下: /* SCHEMA SYNONYMS will be added in 12g */ -- insert into au