Insert Text Literal and Concatenation in Oracle SQL Ievietot teksta gramatisko un konkatenācija ar Oracle SQL
In Oracle, it's possible to insert literal or concatenate 2 or more charater strings or SQL result output together. Oracle, ir iespējams ievietot gramatisko vai saķēdēt 2 vai vairāk charater virknes vai SQL rezultāts izejas kopā. This manipulation allows you to manipulate the format of data returned by SQL query. Šajā manipulācijā ļauj manipulēt formātu datiem, ko SQL vaicājumu.
Two solid vertical bar || operator is used to concatenate 2 or more strings. Divi cietu vertikāla josla | | operators izmanto saķēdēt 2 vai vairāk stīgas. 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. Blakus Oracle nodrošina arī CONCAT raksturs kalpo kā alternatīva vertikāla josla operators tikai gadījumā, ja ir situācija, kad ir grūti vai neiespējami kontrolēt tulkojumu, ko veic operētājsistēmā vai tīklā kom. This function should be used in applications that will be moved between environments with differing character sets. Šī funkcija jāizmanto pieteikumi, kas tiks pārvietotas starp vidi ar atšķirīgu rakstzīmju kopu.
Oracle will automatically casts values into types which can be concatenated. Oracle automātiski rada vērtības pēc to tipiem, kurus var saliktās. 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. Kā Oracle interpretē NULL kā tukšā (nulles garumu) rakstzīmju virkne, tas neatgriež NULL ja operands ir NULL, kas nozīmē concatenating nulles garuma rakstzīmju virkne ar citu operands vienmēr rezultātiem citās operands, lai null var rasties tikai no konkatenācija diviem null stīgas. To concatenate an expression that might be null, use the NVL function to explicitly convert the expression to a zero-length string. Lai saķēdēt izteiksme, kas varētu būt spēkā, izmantot NVL funkcijas skaidri konvertētu izteiksmi uz nulles garuma virkni.
Concatenating two strings results in another character string. Concatenating divas virknes rezultātā citu rakstzīmju virkni. If both character strings are of datatype CHAR, the result has datatype CHAR and is limited to 2000 characters. Ja abas rakstzīmju virknes ir datatype CHAR, rezultāts datatype CHAR un ir ierobežots līdz 2000 rakstzīmēm. If either string is of datatype VARCHAR2, the result has datatype VARCHAR2 and is limited to 4000 characters. Ja kāds no virknes ir datatype VARCHAR2, rezultāts datatype VARCHAR2 un ir ierobežots līdz 4000 rakstzīmēm. Trailing blanks in character strings are preserved by concatenation, regardless of the strings' datatypes. Trailing sagataves raksturs, stīgas konservēti konkatenācija neatkarīgi no virknes "datatypes.
For literal insertion, put the strings between the single quote ' in the SQL statement. Par gramatisko ievietošanas, ielieciet virknes starp vienu citātu ", kas SQL.
Example and Usage : Piemērs un Usage:
SELECT 'Name is ' || name FROM table; SELECT "nosaukums ir" | | name FROM table;
Name is whatever_name Nosaukums ir whatever_name
SELECT number || ' – ' || description FROM table ORDER BY number SELECT numurs | | '-' | | Apraksts FROM tabula ORDER BY numurs
1 – description 1 1 - apraksts 1
2 – description 2 2 - apraksts 2
Advance Usage : 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. Ir iespēja izmantot konkatenācija un gramatisko ievietošana radīt kopumu SQL vaicājumu valodas automātiski, jo īpaši, ja vajadzēs veikt pašu darbību daudz tabulas, ti, krītot daudz tabulas. 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. Lai to izdarītu, formāts SQL vaicājumu valodu izvades vaicājumu rezultātu derīgu SQL formātā, un tītavas SQL vaicājuma rezultātus failā. Then execute the file that contains SQL statements. Tad izpildīt fails, kas satur SQL.
Example: Piemērs:
SELECT 'DROP TYPE ' || type_name || ';' Izvēlieties 'DROP TYPE' | | type_name | | '; "
will generates: būs rada:
DROP TYPE type_name DROP TYPE type_name
that can be run at SQL*Plus by calling the file with @filename. ka var palaist SQL * Plus, zvanot ar failu @ filename. All types that been selected from first SQL statements will be dropped from the database. Visi veidi, kas ir izvēlēta no pirmā SQL būs samazinājies no datu bāzes.
IMPORTANT : The page is machine translated and provided "as is" without warranty. SVARĪGI: lapa mašīna iztulkot un pasniegts tàds, "kàds tas ir" bez garantijas. Machine translation may be difficult to understand. Mašīntulkošanas var būt grūti saprast. Please refer to Lūdzu, skatiet original English article oriģināls angļu rakstu whenever possible. kad vien iespējams.
Related Articles Saistītie raksti
- How to Escape Characters in Oracle PL/SQL Queries Kā izvairīties rakstzīmes Oracle PL / SQL vaicājumi
- Use {Literal} Smarty Tag to Add Google Analytics Tracking Code to BlogSome Hosted Blogs Izmantojiet (burtisks) Smarty Tag uz Pievienot Google Analytics uzskaites kodu BlogSome Hosted Blogs
- Oracle EXP-00091 Error When Export Database Oracle EXP-00091 kļūdu Export Database
- Insert and Fill Random Filler Text and Lorem Ipsum Into Office Word, Execel and PowerPoint 2007 Ievietot un Aizpildīt Random Filler Teksts un Lorem Ipsum Into Office Word, Execel un PowerPoint 2007
- Change Oracle Database User Password Maina Oracle Database Lietotājs Parole
- Check Oracle Version Check Oracle Version
- ORA-01502 Oracle Index in Unusable State ORA-01.502 Oracle Index Nederīgas valsts
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database IMP-00016 Nepieciešams Character Set Conversion Not Supported Kļūda Imports Oracle Database
- Manual and Clean Uninstall Oracle for Windows Rokasgrāmata un Clean Uninstall Oracle for Windows
- Oracle ORA-01658 Unable to Create INITIAL Extent for Segment in Tablespace Error Oracle ORA-01.658 Nevar izveidot INITIAL Apjoms, kādā segmentā Tablespace Kļūda










































March 2nd, 2007 21:57 2 marts 2007 21:57
Good article. Labs raksts. Got what I was looking for… Dabūja to, ko es meklēju ...