Insert Text Literal and Concatenation in Oracle SQL Vložte text Literal a zreťazenie v Oracle SQL
In Oracle, it's possible to insert literal or concatenate 2 or more charater strings or SQL result output together. V Oracle, je možné vložiť doslovnom alebo spájať 2 a viac charater reťazcov alebo SQL výsledok výstup spoločne. This manipulation allows you to manipulate the format of data returned by SQL query. Táto manipulácia umožňuje manipulovať s formátom dát vrátených SQL dotazu.
Two solid vertical bar || operator is used to concatenate 2 or more strings. Dve pevná zvislá čiara | | operátor sa používa na spájať 2 alebo viac reťazcov. 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. U, Oracle taktiež charakter CONCAT fungovať ako alternatíva ku zvislej prevádzkovateľ baru len v prípade, že situácia, kedy je ťažké alebo nemožné kontrolovať preklady realizované podľa operačného systému alebo siete verejnej služby. This function should be used in applications that will be moved between environments with differing character sets. Táto funkcia by mala byť použitá v aplikáciách, ktoré sa bude pohybovať medzi prostrediach s rôznymi znakovej sady.
Oracle will automatically casts values into types which can be concatenated. Oracle bude automaticky vrhá hodnoty, na druhy, ktoré môžu byť dlhých. 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. Ako Oracle NULL interpretuje ako prázdne (nula-dĺžka) reťazec znakov, nevráti NULL, ak operand je NULL, znamená zřetězování nula-dĺžka reťazca znakov iným operandov vždy výsledky v druhej operand, takže môže dôjsť iba null od zreťazenie dvoch reťazcov null. To concatenate an expression that might be null, use the NVL function to explicitly convert the expression to a zero-length string. Ak chcete spájať výraz, ktorý by mohol byť Null, použite funkciu NVL explicitne previesť výraz-nulovej dĺžky reťazca.
Concatenating two strings results in another character string. Zřetězování dva reťazce výsledky v inom reťazci znakov. If both character strings are of datatype CHAR, the result has datatype CHAR and is limited to 2000 characters. Ak sú oba reťazce znakov sú Datatyp CHAR, výsledok je dátový typ CHAR, a je obmedzená na 2000 znakov. If either string is of datatype VARCHAR2, the result has datatype VARCHAR2 and is limited to 4000 characters. Ak je niektorý reťazec je Datatyp VARCHAR2, výsledok je dátový typ VARCHAR2, a je obmedzená na 4000 znakov. Trailing blanks in character strings are preserved by concatenation, regardless of the strings' datatypes. Nasledujúcim nulami v reťazca znakov sú chránené zreťazenie, bez ohľadu na dátové typy reťazcov '.
For literal insertion, put the strings between the single quote ' in the SQL statement. Pre vloženie doslovný, dal reťazca medzi jednoduché úvodzovky 'v príkazu SQL.
Example and Usage : Príklad a použitie:
SELECT 'Name is ' || name FROM table; SELECT 'Meno je' | | jmeno FROM tabulka;
Name is whatever_name Meno je whatever_name
SELECT number || ' – ' || description FROM table ORDER BY number SELECT číslo | | '-' | | opis FROM tabulka ORDER BY číslo
1 – description 1 1 - opis 1
2 – description 2 2 - opis 2
Advance Usage : Advance Použitie:
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. Je možné použiť zreťazenie a Literal vloženia vytvoriť súbor SQL dotazu jazyk automaticky, zvlášť keď potrebujete vykonať rovnakú operáciu na mnoho tabuliek, tj zvrhnutie veľa tabuliek. 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. K tomu, formát dát SQL dopytovací jazyk pre výstup výsledku dotazu v platnom formáte SQL a spool SQL dotazu výsledky do súboru. Then execute the file that contains SQL statements. Potom spustiť súbor, ktorý obsahuje SQL príkazy.
Example: Príklad:
SELECT 'DROP TYPE ' || type_name || ';' SELECT 'DROP TYPE' | | type_name | | ','
will generates: sa vytvára:
DROP TYPE type_name DROP TYP type_name
that can be run at SQL*Plus by calling the file with @filename. , Ktoré možno spustiť v SQL * Plus volaním súbor @ filename. All types that been selected from first SQL statements will be dropped from the database. Všetky druhy, ktoré boli vybrané z prvého príkazov SQL budú vypustené z databázy.
IMPORTANT : The page is machine translated and provided "as is" without warranty. Upozornenie: stránka je stroje preložené a za predpokladu, "ako je" bez záruky. Machine translation may be difficult to understand. Strojový preklad môže byť ťažké pochopiť. Please refer to Nájdete na original English article originál Anglicky artikl whenever possible. ak je to možné.
Related Articles Súvisiace články
- How to Escape Characters in Oracle PL/SQL Queries Ako Escape znaky v Oracle PL / SQL dotazov
- Use {Literal} Smarty Tag to Add Google Analytics Tracking Code to BlogSome Hosted Blogs Použite) (Literal Smarty Tag pridať kód sledovania Google Analytics, aby BlogSome Hosted Blogy
- Oracle EXP-00091 Error When Export Database Oracle EXP-00091 Dlh Kedy Export databázy
- Insert and Fill Random Filler Text and Lorem Ipsum Into Office Word, Execel and PowerPoint 2007 Vložiť a Fill Náhodné Filler Text a Lorem Ipsum Do Office Word, Execel a PowerPoint 2007
- Change Oracle Database User Password Zmeniť Oracle Database Užívateľ Heslo
- Check Oracle Version Skontrolujte, Oracle verzia
- ORA-01502 Oracle Index in Unusable State ORA-01502 Oracle Index v Nepoužiteľné štátu
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database IMP-00016 Povinné Character Set Konverzný nepodporovaných Chyba pri dovoze do Oracle Database
- Manual and Clean Uninstall Oracle for Windows Manuálne a Clean Uninstall Oracle pre Windows
- Oracle ORA-01658 Unable to Create INITIAL Extent for Segment in Tablespace Error Oracle ORA-01658 Neschopný až k Menovať POČIATOČNEJ Rozsah pre segment v Tablespace Dlh










































March 2nd, 2007 21:57 2.března 2007 21:57
Good article. Dobrý článok. Got what I was looking for… Dostal to, čo som hľadal ...