Insert Text Literal and Concatenation in Oracle SQL Indsæt tekst bogstavelig og Sammenkædning i Oracle SQL

In Oracle, it’s possible to insert literal or concatenate 2 or more charater strings or SQL result output together. I Oracle, er det muligt at indsætte bogstavelig eller concatenate 2 eller flere charater strenge eller SQL resultat output sammen. This manipulation allows you to manipulate the format of data returned by SQL query. Denne manipulation giver dig mulighed for at manipulere form af data, der returneres af SQL forespørgsel.

Two solid vertical bar || operator is used to concatenate 2 or more strings. To fast lodret bjælke | | operatør bruges til at concatenate 2 eller flere strenge. 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. Ved siden af, Oracle giver også CONCAT karakter fungere som et alternativ til den lodrette bar operatør kun i tilfælde er der situation, hvor det er vanskeligt eller umuligt at kontrollere oversættelse udføres af operativsystemet eller netværk forsyningsvirksomheder. This function should be used in applications that will be moved between environments with differing character sets. Denne funktion bør anvendes i applikationer, der vil blive flyttet mellem miljøer med forskellige tegnsæt.

Oracle will automatically casts values into types which can be concatenated. Oracle vil automatisk kaster værdier i typer, der kan være sammenkædet. 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. Som Oracle fortolker NULL som den tomme (nul-længde) tegnstreng, det ikke returnere NULL, hvis en operand er NULL, jf. concatenating en nul-længde tegnstreng med en anden operand altid resulterer i den anden operand, så null kan kun føre til fra Sammenkædning af to null strenge. To concatenate an expression that might be null, use the NVL function to explicitly convert the expression to a zero-length string. Til concatenate et udtryk, som kan være nul, så brug NVL funktion til eksplicit at konvertere udtryk for en nul-længde streng.

Concatenating two strings results in another character string. Concatenating to strenge resultater i en anden tegnstreng. If both character strings are of datatype CHAR, the result has datatype CHAR and is limited to 2000 characters. Hvis begge tekststreng er af datatype CHAR, resultatet er datatype CHAR og er begrænset til 2000 tegn. If either string is of datatype VARCHAR2, the result has datatype VARCHAR2 and is limited to 4000 characters. Hvis enten strengen er af datatype VARCHAR2, resultatet er datatype VARCHAR2 og er begrænset til 4000 tegn. Trailing blanks in character strings are preserved by concatenation, regardless of the strings’ datatypes. Efterfølgende blanks karakter strings er konserveret ved Sammenkædning, uanset strengene 'datatyper.

For literal insertion, put the strings between the single quote ‘ in the SQL statement. For bogstavelig indsættelse, der sættes i trådene mellem de enkelte anførselstegn 'i SQL-sætning.

Example and Usage : Eksempel og Usage:

SELECT ‘Name is ‘ || name FROM table; Vælg 'navn er' | | navn fra bordet;

Name is whatever_name Navnet er whatever_name

SELECT number || ‘ - ‘ || description FROM table ORDER BY number SELECT antal | | '-' | | beskrivelse fra tabel KENDELSE AF antal

1 - description 1 1 - beskrivelse 1
2 - description 2 2 - beskrivelse 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. Er det muligt at bruge Sammenkædning og Literal Indsættelse at generere et sæt af SQL query sprog automatisk, især når behovet for at udføre samme operation, masser af tabeller, dvs slippe en masse tabeller. 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. For at gøre dette, skal du formatere SQL data query sprog til output forespørgslen resultere i gyldig SQL format, og spool SQL forespørgsel resultater til en fil. Then execute the file that contains SQL statements. Derefter effektuere den fil, der indeholder SQL opgørelser.

Example: Eksempel:

SELECT ‘DROP TYPE ‘ || type_name || ‘;’ Vælg 'DROP TYPE' | | type_name | | '; "

will generates: vil genererer:

DROP TYPE type_name DROP TYPE type_name

that can be run at SQL*Plus by calling the file with @filename. , der kan køre på SQL * Plus ved at kalde filen med @ filename. All types that been selected from first SQL statements will be dropped from the database. Alle typer, der er udvalgt fra første SQL-sætninger, vil være faldet fra databasen.

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. VIGTIGT: Dette er en maskine oversat side som er stillet til rådighed "som de er" uden garanti. Machine translation may be difficult to understand. Maskinoversættelse kan være svært at forstå. Please refer to Der henvises til original English article originale engelske artikel whenever possible. når det er muligt.

Share and contribute or get technical support and help at Aktie og bidrage eller få teknisk support og hjælp på My Digital Life Forums Min digitale liv fora .



One Response to “Insert Text Literal and Concatenation in Oracle SQL” Et svar på "Indsæt tekst ordlyden Sammenkædning i Oracle SQL"

  1. Arun
    March 2nd, 2007 21:57 2 marts 2007 21:57
    1

    Good article. God artikel. Got what I was looking for… Har du, hvad jeg ledte efter ...

Leave a Reply Efterlad et svar

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Du kan bruge disse tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime = ""> <em> <i> <q Cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. Abonner på kommentarer funktion er blevet deaktiveret. To receive notification of latest comments posted, subscribe to Til at modtage anmeldelse af seneste kommentarer udstationeret, abonnere på My Digital Life Comments RSS feed Min digitale liv Kommentarer RSS-feed or eller register to receive register til at modtage new comments in daily email digest. nye kommentarer i e-mail dagligt fordøje.
Custom Search

New Articles Nye Artikler

Incoming Search Terms for the Article Indkommende søgeord til artikel

oracle escape concatenate Oracle undslippe concatenate - --