單引號:數據庫
- 表示字符串常量,並不區分大小寫。。
- 字符串中的雙引號僅僅被看成一個普通字符進行處理。此時,雙引號不須要成對出現。
- 轉義符,對緊隨其後出現的字符(單引號)進行轉義 ' '' ' ----> '
- 用於,字符串數據的操做,如建立表,查詢,刪除,添加,數據等
SQL> select 'hh24"小時""mi"分"""ss"秒"' AS RESULT from dual; RESULT ----------------------------------------- hh24"小時""mi"分"""ss"秒" SQL> select '' from dual; ' - SQL> select ''' from dual; ERROR: ORA-01756: quoted string not properly terminated #轉移字符單引號 SQL> select '''' from dual; ' - ' SQL> select ' '' ' from dual; ''' --- ' SQL> select ' '''' ' from dual; '''' ---- ''
雙引號:oracle
- 假如創建對象的時候,對象名、字段名加雙引號,則示意 Oracle將嚴格區分大小寫,不然Oracl都默認大寫。
- 用於表名,字段名, 別名
- 出如今to_char的格式字符串中時,雙引號有特殊的做用,就是將非法的格式符包裝起來
- 用於建立用戶時的密碼,DB_link, 多用於數據庫的操做
SQL> select to_char(sysdate, 'hh24"H"mi"M"ss"S"') AS RESULT from dual; RESULT --------- 07H08M37S #建立User CREATE USER CH1 IDENTIFIED BY 'pass' DEFAULT TABLESPACE TBS_01 TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; Error at line 1 ORA-00988: missing or invalid password(s) CREATE USER CH1 IDENTIFIED BY "pass" DEFAULT TABLESPACE TBS_01 TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; #建立DB_Link CREATE DATABASE LINK "ORCL_HR.QA.WEBEX.COM" CONNECT TO HR IDENTIFIED BY "pass" USING 'tony1521'; SQL> select first_name from emp where "employee_id" = 200; select first_name from emp where "employee_id" = 200 * ERROR at line 1: ORA-00904: "employee_id": invalid identifier SQL> select first_name from emp where "EMPLOYEE_ID" = 200; FIRST_NAME ---------------------------------------- Jennifer SQL> select first_name as "name" from emp where employee_id = 200; name ---------------------------------------- Jennifer SQL> select first_name 'name' from emp where employee_id = 200; select first_name 'name' from emp where employee_id = 200 * ERROR at line 1: ORA-00923: FROM keyword not found where expected
注意ide
SQL> select first_name as "name" from emp where employee_id = 200; --數字 name ---------------------------------------- Jennifer SQL> select first_name as "name" from emp where employee_id = '200'; --字符 name ---------------------------------------- Jennifer SQL> select first_name as "name" from emp where employee_id = "200"; select first_name as "name" from emp where employee_id = "200" * ERROR at line 1: ORA-00904: "200": invalid identifier #在oracle10g中能夠運用其它分隔符($,<>,[],{}等),留心,運用這些分隔符時,不只要在分隔符先後加單引號,還要帶有前綴q. SQL> SELECT 'D''COSTA' name FROM DUAL; NAME ------- D'COSTA SQL> SELECT q'$D'COSTA$' NAME FROM DUAL; NAME ------- D'COSTA SQL> SELECT q'[D'COSTA]' NAME FROM DUAL; NAME ------- D'COSTA SQL> SELECT q'<D'COSTA>' NAME FROM DUAL; NAME ------- D'COSTA ' #假如創建對象的時候,對象名、字段名加雙引號,則示意 Oracle將嚴格區分大小寫,不然Oracl都默認大寫 SQL> create table test(a varchar2(10), a varchar2(10)); create table test(a varchar2(10), a varchar2(10)) * ERROR at line 1: ORA-00957: duplicate column name SQL> create table test("a" varchar2(10), a varchar2(10)); Table created. SQL> desc test; Name Null? Type ----------------------------------------- -------- ---------------------------- a VARCHAR2(10) A VARCHAR2(10) SQL> create table test_1(a varchar2(1), "A" varchar2(1)); create table test_1(a varchar2(1), "A" varchar2(1)) * ERROR at line 1: ORA-00957: duplicate column name