1. 程式人生 > >[20170728]oracle保留字.txt

[20170728]oracle保留字.txt

提示 tab 關鍵字 備份 fyi follow time sage number

[20170728]oracle保留字.txt

--//oracle有許多保留字,我印象最深的就是使用rman備份表空間test,test就是rman裏面的保留字.
--//還有rman也是rman裏面的保留字.如果在應用中盡量規避不要使用這些保留字.

--//探究一下,oracle內部是否也會不小心這些關鍵字.

1.環境:
[email protected]> @ 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

[email protected]

/* */> @ 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

[email protected]
/* */> 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

[email protected]
/* */> select * from V$RECOVER_FILE;
no rows selected

[email protected]> 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.
--//規避它使用雙引號,並且註意要大寫:

[email protected]> select file#,"ONLINE",ERROR, TIME,CON_ID from V$RECOVER_FILE;
no rows selected
--//其他字段沒問題,除了ONLINE字段.

[email protected]> 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


[email protected]> alter database datafile 9 offline;
Database altered.

[email protected]> 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

[email protected]> 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

[email protected]> recover datafile 9;
Media recovery complete.

[email protected]> alter database datafile 9 online;
Database altered.

總之:
--//在應用中盡量規避這些保留字,避免不必要的麻煩!!
--//在11g下再補充一些例子:

[email protected]> @ &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

[email protected]> 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

[email protected]> 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

[email protected]> 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

相關推薦

[20170728]oracle保留.txt

提示 tab 關鍵字 備份 fyi follow time sage number [20170728]oracle保留字.txt--//oracle有許多保留字,我印象最深的就是使用rman備份表空間test,test就是rman裏面的保留字.--//還有rman也是rm

oracle保留在mybatis的使用注意

在宣告列的時候將欄位名全部大寫,並且加上雙引號 <sqlid="Base_Column"> Id, "LEVEL" </sql> 在where條件語句後同上 <

oracle中的關鍵字 保留

官方文件說明: Reserved words and keywordsare identifiers that have special meaning in PL/SQL. You cannot use reserved words as ordinary user-d

Oracle 修改段順序的兩種方法

font update 建表 ont != har 使用 objects class 分類: Oracle 如果要修改字段順序,一般情況可以使用以下步驟: --(1)備份目標表數據 create table 臨時表 as select * from 目標表;

oracle符函數

ace 需要 字符串截取 替代 操作 subst dual 進行 str Upper(字符串 / 列):將輸入的字符串變成大寫 Lower(字符串 / 列):將輸入的字符串變成小寫 Initcap(字符串 / 列):開頭首字母大寫 Length(字符串 / 列):字符串長度

JavaScript筆記3--標識符和保留

package catch abs var con syn init ace fine 1.標識符 javaScript標識符必須以字母,下劃線(_)或美元符($)開始.後續的字符可以是字母/數字/下劃線/美元符.也可以使用非英語語言或數學符號來書寫標識符; 2.保留字 b

oracle al32utf8 符長度

ima ora oracl 字符 length rac image .com 分享 長度為8 。 存的時候 原數據庫中的中文數據為 一個漢字二個字節。新的數據庫 字符集為 al32utf8 中 一個漢字為 三個字節存。 所以,現修改原數據庫char類型為原長3倍。

oracle 修改 段名稱

add drop pan mil spa update rop lib lob 暫時應該沒有對應的方法,所以我用自己想好的方法去修改 /*修改原字段名name為name_tmp,是將想改名稱的字段改為沒用/臨時的字段*/ Alter table 表名 rename

Oracle修改段類型方法小技巧

一個 modify 地址 更改 總結 問題 數據 str details 有一個表名為tb,字段段名為name,數據類型nchar(20)。1、假設字段數據為空,則不管改為什麽字段類型,可以直接執行:alter table tb modify (name nvarchar2

MySQL,Oracle中空符串和NULL

oracl 字符串 空字符 sql name pda 不起作用 作用 upd Mysql 中空字符串和NULL是不一樣的。 Oracle中空字符串就是NULL。 update User set realname =‘‘ where name = "ff"; -- 在O

javascript保留

pri package private switch xtend boolean ext else ret abstract · boolean · break · byte · case · catch · char · class · const · cont

Javascript系列(一)語法、關鍵保留、變量

javascript ECMA是European Computer Manufacturers Association的縮寫,即歐洲計算機制造商協會。歐洲計算機制造商協會是制定信息傳輸與通訊的國際化標準組織。ECMAScript是ECMA制定的標準化腳本語言。目前JavaScript使用的ECMAS

java批量生成用例腳本-保留關鍵詞的用例腳本生成

pri rgs int contain pda eight wid nal order 20171012新補丁包程序,程序整理了全部的關鍵字和保留字,支持 字段a = "字段b" 與 字段a = 字段b,並做了代碼重構。對補丁包進行關鍵字專項測試,驗證關鍵字保留字作為庫、表

oracle 排序段自增長

url rip clas val tlab 微信 span name add <insert id="insertGoodsDescription" parameterClass="goodsDescription" > <selec

三、關鍵字和保留

img column 保留 tar 技術分享 out clas col area 關鍵字和保留字: 三、關鍵字和保留字

Oracle 切割符查詢

substr 切割 post views pla class dsm content evel Oracle 切割字符查詢 select * from vie

Java 中的關鍵字和保留

width interface continue rac borde ctf got break order 關鍵字: Java 語言中已經事先定義好了的,有著特殊含義和用途 訪問控制 類、方法和變量修飾符 程序控制 異常處理 包相關 基本類型 變量引用 publ

java中“53”個關鍵字(含2個保留

xtend bool 怎麽 swing 繼續 接口實現 nds 大括號 trac 1.java的關鍵字(keyword)有多少個? 51+2個保留字=53個關鍵字(java的關鍵字都是小寫的!!) 2.java的保留字(reserve word)有多少個?問題:分

oracle符串拆分

HERE loop num subst pan split ring 字符串拆分 limit 在工作當中發現oracle沒有提供字符串切割函數,在網上找到一個比好的切割方式,記錄一下: 1.新建數據類型 CREATE OR REPLACE TYPE STR_SPLIT

oracle導入TXT文件

oracl control ans lin user spa span china value oracle導入TXT文件: 1、建好對應的表和字段;2、新建test.ctl文件,用記事本編輯寫入: OPTIONS (skip=1) load data INFILE