How do I insert all the records in another table when I process MySQL data in bulk? Please master can directly give the code, thank you!
For example, there are several data in the Database member table, you want to add two fields
Label: drop database if exists school; Delete if school is presentCREATE DATABASE School; Building a library schoolUse School; Open Library SchoolCREATE TABLE Teacher (//Build tables TeacherID int (3) auto_increment NOT NULL primary key,name Char (TEN) is not NULL,address varchar (+) Default ' Shenzhen ',Year date); End of Build table//Below is the Insert fieldIN
Label:Memo: 1. The search found that MySQL does not support the direct write SQL statement to implement the loop insertion function. To do this, you can either manipulate MySQL in another language or use a stored procedure to implement it (store PROCEDURE--SP). 2. The following is an SP implementation pass, write down to be afraid to forget. --Table structure
Insert a large amount of data into a table in the MySQL database:
Usage:
DELIMITER $USE 'macross _ wudi '$Drop procedure if exists 'test' $Create procedure 'test '()BEGINDECLARE I INT DEFAULT 333;DECLARE j int default 333;WHILE (I Replace into fs_mobile_ms_dat VALUES (I, 669, j, 'Guest ', 'running', '2017-10-10', '2017
)
4 of the same data has been successfully copied, which makes it easier for us to test data.
The above statement is more suitable for data interpolation in two tables, if multiple tables are not adapted. For multiple tables, you can join the fields you want to query, then make a view and select from:
The code is as follows
Copy Code
'Must click the menu "Project/reference/Microsoft Word 9.0 Object Library"Dim WD as new word. Application'Insert a table with three columns and six rows and insert data to each table row.WD. Documents. Add documenttype: = wdnewblankdocumentSet odoc = WD. activedocumentSet otable = odoc. Tables. Add (range: = odoc. Rang
Label:EXEC sp_addlinkedserver
@server = ' cqq ',--the server alias that was accessed (habitually using the target server IP directly, or taking an individual name such as JOY)
@srvproduct = ' ms ',
@ Provider= ' SQLOLEDB ',
@datasrc = ' 172.18.5.9 '--the server to be accessed
EXEC sp_addlinkedsrvlogin
@rmtsrvname = ' cqq ',-- The server alias being accessed (if the alias joy is used in the sp_addlinkedserver above, Joy is also here)
@useself = ' false ',
@locallogin =null,
@rmtuser = ' S
Tags: padding val bool span syntax takes time option offUse the INSERT INTO SQL statement in the MySQL table to insert the data. You can insert data into a
(1): Query whether a table exists in a database ( two ways): Assuming that the table name is table_nameif exists (select * from sysobjects where name= ' table_name ')DROP TABLE table_nameIf OBJECT_ID (' table_name ') is NOT nullDROP TABLE table_nameThe same operation can also be used to determine whether the database e
Link: http://www.it118.org/Specials/c9fba99e-4401-49cf-8256-ac3c1a34c0d9/cf2a7ceb-1815-43fe-8810-47af11ac65a9.htm
Two methods can be implemented without using a cursor. The following two methods provide better performance than a cursor.
1. INSERT INTO SELECT This method is usually used when the target table already exists in the Database. You need to insert
Tags: style color data div on SP SQL CBulk Insert Table (table data Sheet) * * * *1.INSERT into SELECT statementThe statement form is:Insert into Table2 (field1,field2,...) Select Value1,value2,... from Table1Requires that the tar
1/Set up data tables firstCREATE TABLE basicmsg(Recvtime FLOAT not NULL,--Receive time, no data with the same timeAA INT not NULL,--24-bit address code.Flightid Varchar () NULL,-flight number)2/Set up stored proceduresUse Df17dataproIF EXISTS (SELECT * from SYS.) Procedures WHERE object_id = object_id (N ' [dbo].[ Bulkdataproc]))DROP PROC [DBO]. [Bulkdataproc]GO-
In the Android development process, often to use SQLite to store some data, this application should be more common, but sometimes unavoidably inadvertently, will appear sqlite create table success, insert not error, but no data inserted.For specific questions, see the following code:Context CTX;Sqlitedatabase db = Dbop
muchUsage:select Name as Student_name from Student LIMIT 3;Look for the display name alias Student_name, showing only the first 3 dataUsage:select Name as Student_name from Student LIMIT 2, 2;Find Display name alias is Student_name, offset off the first 2 data is not displayed, display the 2nd data after 2 datamysql> SELECT Name as Student_name from Student LIMIT 3;+--------------+| Student_name |+--------
However, during the development and testing processes, we often encounter situations where table replication is required, such as copying some of the data fields of Table 1 to table 2 or copying the entire table 1 to table 2, in t
Copy CodeThe code is as follows:
Set ANSI_NULLS on
SET QUOTED_IDENTIFIER ON
Go
-- =============================================
--Author: Hua Ling
--Create date:2008-10-28
--Description: Generate Insert script for table data
--demo:exec Pcreateinsertscript ' bexmcodetype ', ' Dictypeid = 61 '
-- =============================================
ALTER proc [Dbo].pcrea
Package order table; Import Java.util.arraylist;import Java.util.scanner;public class OrderList {/** * @param args * @author Liu Yanbing * @2015-1-31 21:00 *//* * (The following so-called "position" is not an array subscript notation starting from 0, but a representation starting from 1.) * (for example, the data on position 2 in 12,13,14,15,16 data is 13) * * Us
(sum(In_total_price)/sum(In_amount),2) as 'Junjia',Count(*) fromScm.in_warehouse_detail6 Group byGoods_id,goods_type,goods_name7 Order byGoods_id,goods_type,goods_name;Source---------If the current database contains an average price temporary table is deleted---------DROP TABLE IF EXISTSavg_prices;---------Create an average temp table and populate the query r
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.