Use INSERT INTO (field1,field2 ...) VALUES (' Val1 ', ' val2 ' ...) , an error occurs if there is a single quotation mark in the value.Processing method: Determine whether the Val1,val2 contains single quotation marks, if the single quotation marks, then the single quotation mark ' replaced with two single quotation marks '.Organize fields and field values into a hashtable, and then abstract a function getsqlbyhashtable () that organizes SQL statements:HashTable HT =new HashTable ();Ht.add (FIEL
Label:Note that you cannot omit any of the fields in the table. Include self-increment ID The principle is "table interpolation table" INSERT intoprod_attrSelectA.* from
(
SELECT
5 asprod_id,1 asattr_id,'China Press' asAttr_valueUNION
SELECT
5 asprod_id,2 asattr_id,'Tsinghua Press' asattr_value) asA Table structure MySQL Insert insert new fo
1 Declare @dt datetime,@today datetime,@a varchar(Max),@z datetime Set @a=02 Select @today=CONVERT(varchar( -),GETDATE(), -),@dt=@today3 while @a14 begin5 Select @today=CONVERT(varchar( -),GETDATE(), -)6 7 while @dt=@today8 begin9 InsertProjectmanageValues('installed BB'+@a,'Xiao Ming',' Daming','Engineering Supervision','is a',@dt,'2000-9-9','13527748096','13527748096','13527748096','13527748096','13527748096','13527748096')Ten Set @dt=DATEADD(SECOND,5,@dt) One End A Set @a=@a
1 Insert into Table(Field1,field2,...)Values(Value1,value2,...)--inserting A single piece of data2 3 Insert into Table(Field1,field2,...)SelectValue1,value2,...Union SelectValue1,value2,...--Insert multiple data, do not allow default4 5 Insert intoTable2 (Field1,field2,...)SelectField1,field2,... fromTable1--table 2 must be present6 7 SelectField1,field2,... intoTable2 fromTable1--CREATE table 2, copy table 1 data to table 2Several ways in which SQL Server
order by id desc limit) se Lect avg (load_15) from S) where Id=new.id;return new; END; $BODY $ LANGUAGE plpgsql VOLATILE cost 100; Using Pgsql to write a trigger function, the basic idea is actually update. Add a trigger to a tableCREATE TRIGGER Trg_status_loadavg_insert After insert in asset_serverstatus for each ROW EXECUTE PROCEDURE Fn_status_loada Vg_insert (); In this way, the implementation of a field is averaged in the PostgreSQL database and then inserted into another field, depending o
] [nvarchar] (a) not null,[detailage] [i NT] not null,[createtime] [datetime] is not NULL);Dbo. F_rtnstrbysplitindex is a custom scalar-valued function that returns the string corresponding to the first number of delimiters, such as dbo. F_rtnstrbysplitindex (' Jack|lilei|tom|nike ', 3) returns TomHere is the creation of the functionCreate function [dbo]. [F_rtnstrbysplitindex] (@procStr nvarchar (max), @splitStrIdx int) returns nvarchar (+) asbegindeclare @rtnStr nvarchar (+) DECLARE @ Currents
two doubts, please advise:1. If the entity must be obtained at the time of update and delete, and then the operation can be performed, I try to get the entity in the database without going to the databases at the time of update, but declare an entity myself and then delete it, but it fails.2. In the generated update and delete conditional statements contain [email protected] and [email protected] statements, supposedly link to SQL already know the ID is the only primary key, why also pass these
primary key, so if you can create a primary key for the table, you can use this advantage to improve the efficiency of importing data.
Perform set unique_checks=0 before importing data, turn off uniqueness Check, execute set unique_checks=1 after import, restore uniqueness check, can improve efficiency of import.
If your app uses autocommit, it is recommended that you execute set autocommit=0 before importing, turn off autocommit, set autocommit=1 after import, turn on autocommit, or in
Label:Inserting data into a table using the Insert SELECT -- Add the data inserted in T1 to T2 (the T2 table must exist, and the order, data type must be consistent with T1)
INSERT into T2 (Username,password)
SELECT from T1
Use SELECT into to add data from an existing table to a new table -- Add the data that is queried in T1 to T2 (the T2 table cannot exist.) will be created in execution)
SELECT t1_username, T1_password
into from T1 To insert an identity column: -- when
--The first of these cases1 if the field of 2 tables is consistent and you want to insert all the data, you can use this method:INSERT into target table SELECT * from source table;2 "For example, to insert the articles table into the Newarticles table, it is:INSERT into Newarticles SELECT * from articles;3 If you want to import only the specified fields, you can use this method:INSERT into Target table (field 1, Field 2, ...) SELECT Field 1, Field 2, ... From source table;--Here's the second cas
--Establish table test1CREATE TABLE TEST1(ID VARCHAR2 (+) default Sys_guid (),Tdate VARCHAR2 (200))Tablespace App_tx_dataPctfree 10Pctused 40Initrans 1Maxtrans 255Storage(Initial 64KMinextents 1Maxextents Unlimited);--Insert Date time Format dataINSERT into test1 values (Sys_guid (), sysdate+10);--Querying dataSELECT * FROM Test1--tdate value is January-July-15--q: How do I brush an existing data January-July-15 format into a normal YYYYMMDD format?Update Test1 t Set t.tdate = ' 20 ' | | substr
Label: 1 require"Database.php";
2
3 $po _code= "Ymwf2015-6-25-1";
4 $customer= "Youmei";
5 $confirm _date= "2015-6-25";
6 $delivery _date= "2015-7-25";
7
8 $create _order_sql= "INSERT into ' ld_crm '. ' Order ' (' id ', ' po_code ', ' Customer ', ' confirm_date ', ' delivery_date ') VALUES (NULL, '$po _code‘, ‘$customer‘, ‘$confirm _date‘, ‘$delivery _date‘)";Note the previousThe ' Ld_crm ' is not a single quote but a sign of the key below the ESC. Variables in the following values cannot use
This article will introduce iBATIS batch data insertion to the database. I hope this article will help you.
Using callback interfaces in the iBATIS framework also enables batch data operations to reduce the number of accesses to the database and improve performance. The following is an example of batch data insertion into an Oracle database using the iBATIS framework:
Batch Data insertion:
The Code is as follows:
Copy code
/*** Ibatis
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.