Insert Text Literal and Concatenation in Oracle SQL Chèn văn bản từng chữ và trong Concatenation Oracle SQL
In Oracle, it's possible to insert literal or concatenate 2 or more charater strings or SQL result output together. Trong Oracle, có thể chèn thêm các literal concatenate hoặc 2 hoặc nhiều hơn charater strings SQL hoặc kết quả đầu ra lại với nhau. This manipulation allows you to manipulate the format of data returned by SQL query. Thao tác này cho phép bạn thao tác định dạng dữ liệu trả về của truy vấn SQL.
Two solid vertical bar || operator is used to concatenate 2 or more strings. Hai rắn dọc thanh | | nhà điều hành được sử dụng để concatenate strings 2 hoặc nhiều hơn. 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. Bên cạnh, Oracle cũng cung cấp các chức năng CONCAT ký tự như là một lựa chọn thay thế dọc quầy bar nhà điều hành, trong trường hợp chỉ có nơi đó là tình hình khó khăn hoặc không thể kiểm soát dịch thực hiện bởi hệ điều hành hoặc tiện ích mạng. This function should be used in applications that will be moved between environments with differing character sets. Chức năng này nên được sử dụng trong các ứng dụng đó sẽ được di chuyển giữa các môi trường khác nhau với các ký tự đặt ra.
Oracle will automatically casts values into types which can be concatenated. Oracle sẽ tự động casts giá trị vào loại này có thể được 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. Oracle là dịch như là trống rỗng, Null (không dài) chuỗi ký tự, không trả lại nếu một Null operand là Null, có nghĩa là một số không concatenating dài chuỗi ký tự khác với operand luôn luôn kết quả trong operand khác, do đó, kết quả chỉ có thể null từ concatenation của hai null strings. To concatenate an expression that might be null, use the NVL function to explicitly convert the expression to a zero-length string. Để concatenate một biểu rằng có thể là null, NVL sử dụng các chức năng để chuyển đổi rõ ràng những biểu cho một số không dài chuỗi.
Concatenating two strings results in another character string. Concatenating hai strings kết quả trong một chuỗi ký tự. If both character strings are of datatype CHAR, the result has datatype CHAR and is limited to 2000 characters. Nếu cả hai ký tự strings đang có dư liệu của Char, kết quả có dư liệu Char và được giới hạn trong 2000 ký tự. If either string is of datatype VARCHAR2, the result has datatype VARCHAR2 and is limited to 4000 characters. Nếu một trong hai chuỗi là của dư liệu VARCHAR2, kết quả có dư liệu VARCHAR2 và được giới hạn trong 4000 ký tự. Trailing blanks in character strings are preserved by concatenation, regardless of the strings' datatypes. Trailing blanks trong strings ký tự được bảo tồn của concatenation, bất kể strings' datatypes.
For literal insertion, put the strings between the single quote ' in the SQL statement. Đối với từng chữ chèn, đưa strings giữa các đơn báo giá 'trong SQL statement.
Example and Usage : Ví dụ và Cách sử dụng:
SELECT 'Name is ' || name FROM table; CHỌN 'Tên là' | | TỪ bảng tên;
Name is whatever_name Tên là whatever_name
SELECT number || ' – ' || description FROM table ORDER BY number CHỌN số | | '-' | | bảng mô tả TỪ ĐẶT HÀNG THEO số
1 – description 1 1 - mô tả 1
2 – description 2 2 - mô tả 2
Advance Usage : Nâng cao Cách sử dụng:
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. Có thể sử dụng và Concatenation literal Chen để tạo ra một bộ các truy vấn SQL sẽ tự động ngôn ngữ, đặc biệt là khi cần phải thực hiện cùng một hoạt động rất nhiều để bàn, tức là giảm rất nhiều bàn. 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. Để làm điều này, các định dạng dữ liệu SQL truy vấn ngôn ngữ để sản xuất các kết quả truy vấn SQL trong định dạng hợp lệ, và spool các truy vấn SQL kết quả vào một tập tin. Then execute the file that contains SQL statements. Sau đó, thực hiện các tập tin có chứa SQL kê.
Example: Ví dụ:
SELECT 'DROP TYPE ' || type_name || ';' CHỌN 'thả LOẠI' | | type_name | | ';'
will generates: sẽ tạo ra:
DROP TYPE type_name Thả LOẠI type_name
that can be run at SQL*Plus by calling the file with @filename. có thể được chạy vào lúc SQL * Plus bằng cách gọi các tập tin với tên tập tin @. All types that been selected from first SQL statements will be dropped from the database. Tất cả các loại hình đó được lựa chọn từ SQL kê đầu tiên sẽ được tụt xuống từ cơ sở dữ liệu.
IMPORTANT : The page is machine translated and provided "as is" without warranty. Lưu ý: Các trang web là máy tính dịch và cung cấp "như là" mà không có bảo hành. Machine translation may be difficult to understand. Máy dịch thuật có thể là khó hiểu. Please refer to Xin vui lòng tham khảo original English article Tiếng Anh bản gốc bài viết whenever possible. bất cứ khi nào có thể.
Related Articles Bài viết liên quan
- How to Escape Characters in Oracle PL/SQL Queries Làm thế nào để ký tự trong Escape Oracle PL / SQL Queries
- Oracle EXP-00091 Error When Export Database Oracle EXP-00091 Lỗi Khi Xuất nhập khẩu Cơ sở dữ liệu
- Insert and Fill Random Filler Text and Lorem Ipsum Into Office Word, Execel and PowerPoint 2007 Chèn và Điền Filler ngẫu nhiên chữ và Lorem Ipsum vào Office Word, Execel và PowerPoint 2007
- Change Oracle Database User Password Cơ sở dữ liệu Oracle thay đổi người dùng Mật khẩu
- Check Oracle Version Kiểm tra phiên bản Oracle
- ORA-01502 Oracle Index in Unusable State ORA-01502 Oracle Index trong unusable Nhà nước
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database IMP-00016 yêu cầu ký tự không được hỗ trợ chuyển đổi Đặt Lỗi khi nhập vào cơ sở dữ liệu Oracle
- Manual and Clean Uninstall Oracle for Windows Hướng dẫn và sạch Gỡ cài đặt Oracle cho Windows
- Oracle ORA-01658 Unable to Create INITIAL Extent for Segment in Tablespace Error Oracle ORA-01658 Không thể Tạo Initial Mức cho phân trong Tablespace Lỗi
- Oracle Database Import Error 3113/3114 Cơ sở dữ liệu Oracle Nhập Lỗi 3113/3114










































March 2nd, 2007 21:57 2 tháng ba, 2007 21:57
Good article. Giải bài báo. Got what I was looking for… Có những gì tôi đã được tìm kiếm ...