Insert Text Literal and Concatenation in Oracle SQL插入文本文字和級聯在甲骨文的SQL
In Oracle, it’s possible to insert literal or concatenate 2 or more charater strings or SQL result output together.在甲骨文,很可能要插入文字或串連2個或以上charater字符串或SQL結果輸出在一起。 This manipulation allows you to manipulate the format of data returned by SQL query.這種手法可以讓你操縱的格式的數據傳回的SQL查詢。
Two solid vertical bar || operator is used to concatenate 2 or more strings.兩個固體豎線| |運營商是用來串連2個或更多的字符串。 Beside, Oracle also provides the CONCAT character function as an alternative to the vertical bar operator just in case there is situation where it is difficult or impossible to control translation performed by operating system or network utilities.旁邊,甲骨文公司還提供了CONCAT性質功能作為替代的垂直線運營商中,以防萬一有情況下,這是很難或根本不可能控制翻譯完成的作業系統或網絡設施。 This function should be used in applications that will be moved between environments with differing character sets.此功能應該用在應用程序,將遷往環境之間具有不同的字符集。
Oracle will automatically casts values into types which can be concatenated.甲骨文公司將自動進入人們的價值類型,可級聯。 As Oracle interprets NULL as the empty (zero-length) character string, it doesn’t return NULL if an operand is NULL, meaning concatenating a zero-length character string with another operand always results in the other operand, so null can result only from the concatenation of two null strings.正如甲骨文公司解釋空的空(零長度)字符串,它不會返回空,如果操作為NULL ,這意味著concatenating零長度字符串與另一運算結果總是在其他操作,因此無效只能產生從串連的兩個空字符串。 To concatenate an expression that might be null, use the NVL function to explicitly convert the expression to a zero-length string.串連表達可能無效,使用NVL職能轉換,明確表達了零長度字符串。
Concatenating two strings results in another character string. Concatenating兩串結果在另一個字符串。 If both character strings are of datatype CHAR, the result has datatype CHAR and is limited to 2000 characters.如果這兩個字符串的數據類型是煤焦,結果有數據類型CHAR和僅限於2000年字符。 If either string is of datatype VARCHAR2, the result has datatype VARCHAR2 and is limited to 4000 characters.如果字符串的數據類型VARCHAR2 ,結果有數據類型VARCHAR2 ,限4000個字符。 Trailing blanks in character strings are preserved by concatenation, regardless of the strings’ datatypes.尾隨空白字符串保存的串連,無論字符串'數據類型。
For literal insertion, put the strings between the single quote ‘ in the SQL statement.對於字面的插入,把弦之間的單引號'的SQL語句。
Example and Usage : 例如和用法:
SELECT ‘Name is ‘ || name FROM table; 選擇'的名字是' | |名稱表;
Name is whatever_name名稱whatever_name
SELECT number || ‘ - ‘ || description FROM table ORDER BY number 選擇若干| | ' -' | |描述表的O RDERB Y人數
1 - description 1 1 -說明1
2 - description 2 2 -說明2
Advance Usage : 提前用法:
It’s possible to use Concatenation and Literal Insertion to generate a set of SQL query language automatically, especially when need to perform same operation to lots of tables, ie dropping a lot of tables.它可以使用級聯插入和文學產生了一整套SQL查詢語言自動,特別是當需要執行相同的行動,以大量的表格,即下降了很多表格。 To do this, format the SQL data query language to output the query result in valid SQL format, and spool the SQL query results to a file.要做到這一點,格式的SQL數據查詢語言輸出的查詢結果在有效的SQL格式和緩衝的SQL查詢結果的文件。 Then execute the file that contains SQL statements.然後執行該檔案,其中包含SQL語句。
Example:例如:
SELECT ‘DROP TYPE ‘ || type_name || ‘;’ 選擇'降型' | | type_name | | ' ; '
will generates:將產生:
DROP TYPE type_name降型type_name
that can be run at SQL*Plus by calling the file with @filename.可以運行的SQL *另外,呼籲該文件@文件名。 All types that been selected from first SQL statements will be dropped from the database.所有類型,被選為第一SQL語句將下降到數據庫中。
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要說明:這是一台機器翻譯網頁這是“原樣”提供,無保修。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原文的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at共享和貢獻或獲得技術支持和幫助 My Digital Life Forums 我的數字生活論壇 . 。
Related Articles相關文章
- Manual and Clean Uninstall Oracle for Windows手冊和乾淨的卸載甲骨文公司針對Windows
- Oracle Database Import Error 3113/3114 Oracle數據庫進口錯誤三千一百一十四分之三千一百十三
- Oracle JDeveloper Reviews甲骨文JDeveloper評語
- Change Oracle Database User Password更改Oracle數據庫用戶密碼
- How to Escape Characters in Oracle PL/SQL Queries如何轉義字符在甲骨文特等/ SQL查詢
- Check Oracle Version檢查甲骨文版
- Oracle Business Activity Monitoring Reviews Oracle商務活動監控評語
- Oracle PL/SQL ORA-00947 Not Enough Values Error甲骨文特等/數據庫口腔00947不夠值誤差
- Oracle Database Link Oracle數據庫鏈接
- ORA-02449 Oracle Drop Table Error口腔02449甲骨文下降表誤差

































March 2nd, 2007 21:57 07年三月2日21時57
Good article.好文章。 Got what I was looking for…得到了我一直在尋找...