oracle string splicing table data usage - "||" oracle string splicing table data usage - "||"

turn:

oracle string splicing table data usage - "||"

 

    Testing process, often need to bulk delete or insert, modify some of the data or table structure, using manual copy, paste is very troublesome, so this is we can use spliced ​​into sql statement to achieve operational data. The following first talk splicing || is the oracle usage, as follows:

The syntax is as follows:

select " "||table.values||" " from tablename where ...

Wherein within quotes are needed stitching string

 

  One example, a table data to clear all the tables:

1, we know, it is the oracle with a number of built-in system tables, such as dba_tables, which contains all the tables and belongs to the oracle user, so that we can delete all the stitching sql table data, and then copy the sql execution on it.

grammar

select 'delete from' || tb.TABLE_NAME || ';' from dba_tables tb where tb.OWNER = 'IOS_BJ' to increase attention spaces when # string concatenation, or will be joined together

Execution results are as follows:

 

 

Example Two, the relationship between the two tables inserted into the third table, spliced ​​to insert into tablename values ​​(parameter, parameter2 .....)

SELECT 'INSERT INTO SMBH_KEFU_WARNING_10019_qx values ( "' || || mm.user_id '", "' ||
(kk.sub4_id || '@' || || kk.sub6_id '@' || kk.eventlevel) || ''); 'user associated with the event relationship SQL
from smbh_kefu_warning_10019 mm, SMBH_KEFU_EVENT_10019 kk
the WHERE mm.cities in (' Yuexiu District ',' Tianhe ') and kk.eventname =' test test '

Execution results are as follows:

 

Special Note:

1, special attention, only the string with single quotation marks " '", can not use double quotation marks
2, if the query string table fields to insert a new field, not directly single quotation marks', and needs two single quotes '' translates

 

 

Reference blog: https: //www.cnblogs.com/chinhr/archive/2011/11/14/2248221.html

      

Category: the Oracle

 

    Testing process, often need to bulk delete or insert, modify some of the data or table structure, using manual copy, paste is very troublesome, so this is we can use spliced ​​into sql statement to achieve operational data. The following first talk splicing || is the oracle usage, as follows:

The syntax is as follows:

select " "||table.values||" " from tablename where ...

Wherein within quotes are needed stitching string

 

  One example, a table data to clear all the tables:

1, we know, it is the oracle with a number of built-in system tables, such as dba_tables, which contains all the tables and belongs to the oracle user, so that we can delete all the stitching sql table data, and then copy the sql execution on it.

grammar

select 'delete from' || tb.TABLE_NAME || ';' from dba_tables tb where tb.OWNER = 'IOS_BJ' to increase attention spaces when # string concatenation, or will be joined together

Execution results are as follows:

 

 

Example Two, the relationship between the two tables inserted into the third table, spliced ​​to insert into tablename values ​​(parameter, parameter2 .....)

SELECT 'INSERT INTO SMBH_KEFU_WARNING_10019_qx values ( "' || || mm.user_id '", "' ||
(kk.sub4_id || '@' || || kk.sub6_id '@' || kk.eventlevel) || ''); 'user associated with the event relationship SQL
from smbh_kefu_warning_10019 mm, SMBH_KEFU_EVENT_10019 kk
the WHERE mm.cities in (' Yuexiu District ',' Tianhe ') and kk.eventname =' test test '

Execution results are as follows:

 

Special Note:

1, special attention, only the string with single quotation marks " '", can not use double quotation marks
2, if the query string table fields to insert a new field, not directly single quotation marks', and needs two single quotes '' translates

 

 

Reference blog: https: //www.cnblogs.com/chinhr/archive/2011/11/14/2248221.html

      

Guess you like

Origin www.cnblogs.com/libin6505/p/11720001.html