Insert Text Literal and Concatenation in Oracle SQL הכנס טקסט מילולי שרשור ב-Oracle ו-SQL
In Oracle, it's possible to insert literal or concatenate 2 or more charater strings or SQL result output together. ב-Oracle, אפשר להכניס CONCATENATE מילולי או 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. שני בר סולידי אנכי | | מפעיל משמש CONCATENATE 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. לצד, Oracle מספקת גם את אופי 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. Oracle באופן אוטומטי מטיל לתוך סוגי ערכים אשר יכולים להיות 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 מפרש ריק כמו ריקה (אפס אורך) מחרוזת התווים, זה לא לחזור ריק אם operand הוא ריק, כלומר אפס concatenating א אורך מחרוזת התווים עם עוד operand תמיד התוצאות האחרות operand, כך ריק יכולים רק תוצאה מתוך שרשור של שתי מחרוזות ריק. To concatenate an expression that might be null, use the NVL function to explicitly convert the expression to a zero-length string. כדי CONCATENATE ביטוי שעשוי להיות ריק, יש להשתמש בפונקציה 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 נתון, התוצאה היא נתון 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. כדורי סרק נגרר אופי מחרוזות נשמרים על ידי שרשור, ללא תלות מחרוזות '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 בחר מספר | | '-' | | תיאור שולחן FROM הזמנה לפי מספר
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 || ';' בחר 'סוג DROP' | | type_name | | ';'
will generates: יהיה יוצר:
DROP TYPE type_name DROP סוג type_name
that can be run at SQL*Plus by calling the file with @filename. כי ניתן להפעיל ב-SQL * Plus על ידי קורא את הקובץ עם @ שם הקובץ. All types that been selected from first SQL statements will be dropped from the database. כל סוגי נבחרת מ SQL תוחודל הראשונה תהיה ירד מ הנתונים.
IMPORTANT : The page is machine translated and provided "as is" without warranty. חשוב: הדף הוא מכונה בתרגום ובתנאי "כמות שהוא", ללא אחריות. Machine translation may be difficult to understand. תרגום מכונה יכול להיות קשה להבין. Please refer to אנא פנה ל original English article המאמר המקורי באנגלית whenever possible. ככל שניתן.
Related Articles מאמרים קשורים
- How to Escape Characters in Oracle PL/SQL Queries איך לברוח תווים Oracle PL / SQL שאילתות
- Oracle EXP-00091 Error When Export Database EXP-00091-Oracle שגיאה כאשר יצא מסד נתונים
- Insert and Fill Random Filler Text and Lorem Ipsum Into Office Word, Execel and PowerPoint 2007 הכנס ומלא אקראיים מלוי טקסט ו Lorem Ipsum לתוך Office Word, Execel ו-PowerPoint 2007
- Change Oracle Database User Password שנה ל-Oracle Database משתמש סיסמה
- ORA-01502 Oracle Index in Unusable State אורה-01502 ב-Oracle אינדקס המדינה לא שמיש
- Check Oracle Version בדוק Oracle גירסה
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database שובב-00016 נדרש התווים המרה אין תמיכה שגיאה כאשר יבוא אל Oracle Database
- Manual and Clean Uninstall Oracle for Windows ידני ונקה Oracle עבור הסרת ההתקנה של Windows
- Oracle ORA-01658 Unable to Create INITIAL Extent for Segment in Tablespace Error אורה Oracle-01658 לא ניתן ליצור הראשונית מידה עבור קטע ב Tablespace שגיאה
- Oracle Database Import Error 3113/3114 Oracle Database ייבוא שגיאה 3113/3114










































March 2nd, 2007 21:57 2 במרץ, 2007 21:57
Good article. מאמר טוב. Got what I was looking for… יש לך את מה שאני מחפש ...