Knowledge points about double quotation marks and single quotation marks in Oracle and Linux

Source: Internet
Author: User

Summary of Oracle and Linux Double quotation marks and single quotation marks in general, we usually use single quotation marks, but when the character set is inconsistent, double quotation marks and single quotation marks are quite different, when using ODBC bridge to import external data, the table name is enclosed by double quotation marks. First case: www.2cto.com has encountered such a problem before. When a friend creates a table, the table name is in lower case, in addition, the table name is enclosed in double quotation marks and the table has been created. However, during the query, the table name does not exist. You can see this table in user_tables, the lower-case table names with double quotation marks are stored in the database and the identifiers expanded with double quotation marks in lower case are stored in the data dictionary as the original case format, the column name is queried in the data dictionary in uppercase format by default. For example: [SQL] sys @ EMREP> 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 sys @ EMREP> create table test ("a" varchar2 (10 ), a varchar2 (10); Table created. sys @ EMREP> SELECT table_name, column_name FROM user_tab_cols WHERE table_name = 'test'; TABLE_NAME COLUMN_NAME ---------------------------- perform TEST a test a sys @ EMREP> insert into TEST values ('1 ', '1'); 1 row created. sys @ EMREP> commit; Commit complete. sys @ EMREP> select * from test; a ---------- 1 1 1 is stored in the data dictionary in an uppercase mode. Verify that sys @ EMREP> create table test_xxxx (A varchar2 (1 ), "A" varchar2 (1); create table test_xxxx (a varchar2 (1), "A" varchar2 (1) * ERROR at line 1: ORA-00957: duplicate column name www.2cto.com is more accurately enclosed by double quotation marks. For example, when we CREATE a table, when we write the CREATE statement, even if the table name is in lower case, all the identifiers stored in the data dictionary are in uppercase, but to store lowercase identifiers in the data dictionary, write CREA. When using a TE statement, you must use double quotation marks. Therefore, the identifier must be case-sensitive, contain spaces in the identifier, or use reserved words as the identifier. You must use the double quotation marks enclosed in double quotation marks: ① indicates that its internal strings are case sensitive. ② It is used for special characters or keywords. ③ it is not subject to the identifier rules. ④ it will be treated as a column. ⑤ when it appears in the to_char format string, double quotation marks have a special role, is to wrap up illegal format characters to avoid the ORA-01821: date format not recognized error, to_char when processing the format string, double quotation marks [SQL] sys @ EMREP> select to_char (sysdate, 'hh24 "Hour" mi "Minute" ss "second" ') are ignored AS RESULT from dual; RESULT ------------------ 17 hours 31 minutes 30 seconds single quotation marks: ① represents a String constant ② Double quotation marks in a string are only treated as a common character Processing. In this case, double quotation marks do not need to appear in pairs, for example, [SQL] sys @ EMREP> select 'hh24 "Hour" "mi" Minute "ss" second "'AS RESULT from dual; RESULT ----------------------------- hh24 "Hour" "mi" Minute "ss" seconds "③ dynamic SQL: In a statement containing a pair of single quotes, A pair of adjacent single quotes must be provided to indicate one single quotes and two adjacent single quotes. The first one is used to indicate escape characters, the following one indicates that the true single quotes must be two consecutive single quotes instead of double quotes. For example: [SQL] select 'alter system kill session ''' | sid | ',' | serial # | ''''; 'From v $ session www.2cto.com when setting variables in linux shell programming, we can use double quotation marks or single quotation marks to control them. A pair of double quotation marks must be a pair of single quotation marks. special characters in a pair are only common characters. special characters in a pair, such as $, can retain the original features. For example, if var = "lang is $ LANG", echo $ var. You can obtain lang is en_US [plain] [root @ localhost ~]. # Name = think [root @ localhost ~] # Echo $ name think [root @ localhost ~] # Ename = "$ name is my English name" [root @ localhost ~] # Echo $ ename think is my English name [root @ localhost ~] # Ename = '$ name is my English name' [root @ localhost ~] # Echo $ ename $ name is my English name. In Oracle, only single quotes are used to represent strings. However, in Linux, single quotes and double quotation marks indicate strings.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.