Oracle中的雙引號的作用

來源:互聯網
上載者:User

1.建表時加雙引號,會保留表名的大小寫寫入資料庫,

注意: 雙引號沒有寫進資料庫,而select時Oracle會預設轉成大寫去資料字典中尋找,當然找不到啦

  1. sys@ziling> conn scott/scott  
  2. 已串連。  
  3. scott@ziling> create table"The"(name varchar2(50));  
  4. 表已建立。  
  5.    
  6. 已選擇 1 行。  
  7. scott@ziling> select * from The;  
  8. select * from The  
  9.               *  
  10. 第 1 行出現錯誤:  
  11. ORA-00942: 表或視圖不存在  
  12.    
  13. scott@ziling> select * from"The";  
  14. 未選定行  
  15. scott@ziling> SELECT segment_name FROMdba_segments where segment_name='The';  
  16. SEGMENT_NAME  
  17. ---------------------------------------------------------------------------------   
  18. The  
  19. 已選擇 1 行。 

2.雙引號用在字串中當成一般字元處理,且不一定要成對出現。

  1. scott@ziling> select 'hh24"小時""mi"分"""ss"秒"' ASRESULT from dual;  
  2. RESULT  
  3. -------------------------   
  4. hh24"小時""mi"分"""ss"秒"  
  5. 已選擇 1 行。  

3.雙引號用在to_char函數裡的字串中時,有特殊作用,可以將特殊字元包起來,避免出現ORA-01821: date format not recognized錯誤。也就是說,去掉雙引號和其包含的字元後,剩下的應該是一個合法的格式串。

select to_char(sysdate, 'hh24"小時"mi"分"ss"秒"') ASRESULT from dual;  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.