insert

Browser crashes when about around 4 million records entered in MYSQL.

hello all I downloaded a database that was exported to the TXT format and has about 700MB with 7 million records (1 per line). I made a script to import the data to a mysql database, but when about 4 million records inserted into, the browser crashes. I have tested in Firefox and IE. Can someone give me an opinion and some advice about ...

assigning data in a new table to an existing foreign key in a for loop

Hi there, I was wondering if there was a way to assign new data in a table to an existing foreign key. For example if i use the following loop to assign randomly generated numbers to columns in the customer table, how would I be able to link cust_id, which I have assigned as a foreign key in the Sales table, with new data created each ti...

(PHP) randomly insert a 10 word sentence into a large text document

I have large text files 140k or larger full of paragraphs of text and need to insert a sentence in to this file at random intervals only if the file contains more then 200 words. The sentence I need to insert randomly throughout the larger document is 10 words long. I have full control over the server running my LAMP site so I can use...

trigger for when a sale is made to update the despatch table

I was wondering how I would go about creating a trigger to update the despatch table once a new sale has been inserted into the sales table. I am guessing that the first few lines of the code will look like this: create trigger sale_trig after insert of sale_id on sales ..... But I am not sure how to do the rest. I am using iSQL Plus. ...

Inserting Line at Specified Position of a Text File in Python

Hi, I have a text file which looks like this: blah blah foo1 bar1 foo1 bar2 foo1 bar3 foo2 bar4 foo2 bar5 blah blah Now I want to insert 'foo bar' between 'foo1 bar3' and 'foo2 bar4'. This is how I did it: import shutil txt = '1.txt' tmptxt = '1.txt.tmp' with open(tmptxt, 'w') as outfile: with open(txt, 'r') as infile: ...

What does database query and insert speed depend on?

At my work we have a small database (as in two hundred tables and maybe a total of a million of rows or so). I've always expected it to be quite fast in the order of several ten of thousands insertion per second and with querys taking milliseconds once the connection is established. Quite the contrary we are having some performance pro...

mysql insert select conundrum

I'm trying to insert select but I'm confused as to how to populate just 1 item into the destination table from the select, and populate the rest with static values. This is all in a stored procedure... so... here's what i'm trying to do... table:animals id |type| name 1 |cat | mittens 2 |cat | fluffy 3 |dog | rex table p...

Rollback insert statement.

Hi, I have inserted some records in one of my table which are upto 5000. But now i realize that these records should not be inserted in this table. I can't delete the records one by one. Or can't distinguish the inserted records for the previous records in the table. How can i rollback this insert statement, so that my table return t...

c# dataset to SQL Server table where datasource originates from CSV

I wanted to know what would be the easiest / best way to get a dataset contained within a datagridview into a sql database. Points to note: The data comes from a CSV file that is imported into the application. The user then has the option to modify cell data They then press a button and hopefully upload to sql table It is given that th...

Concise way to check variable presence in MySQL INSERT QUERY using PHP

I am writing a PHP script to add items to a shopping basket. My shopping basket table has fields for the userid, product id, session id, notes and a few others. Some of the fields can be blank. For example: if someone isn't signed in, then I will store their session id in the table and, if they sign in, add their userid so I have a perm...

inserting into a view in SQL server

I have a SQL Server as backend and use ms access as frontend. I have two tables (persons and managers), manager is derived from persons (a 1:1 relation), thus i created a view managersFull which is basically a: SELECT * FROM `managers` `m` INNER JOIN `persons` `p` ON `m`.`id` = `p`.`id` id in persons is autoincremen...

c# datatable insert column at position 0

Hi, does anyone know the best way to insert a column in a datatable at position 0? ...

Open XML Insert in Temp table - SQL 2005

I have a stored procedure where i am passing a simple XML : '<Products><ProductId>1</ProductId><ProductId>2</ProductId></Products>' I have a @temp table in SQL which has a ProductId Column: DECLARE @Temp TABLE( ProductId NVARCHAR(10) ) I need to write an insert statement which will loop through the ProductId's in the ...

Loop through an XML to insert data in a temp table - SQL 2005

I am trying to execute this (standalone) SQL : Declare @test XML SET @test = '<Products><ProductId>1</ProductId><ProductId>2</ProductId></Products>' DECLARE @Temp TABLE( ProductId NVARCHAR(10) ) INSERT INTO @Temp(ProductId) SELECT tab.col.value('./ProductId[1]','NVARCHAR(10)') AS 'ProductId' FROM @test CROSS APPLY xml_d...

MySQL Selecting count

I have two tables: codes_tags and popular_tags. codes_tags CREATE TABLE `codes_tags` ( `code_id` int(11) unsigned NOT NULL, `tag_id` int(11) unsigned NOT NULL, KEY `sourcecode_id` (`code_id`), KEY `tag_id` (`tag_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 popular_tags CREATE TABLE `popular_tags` ( `id` int(10) unsigned DEFAULT NU...

Choosing the highest scored results from a table variable in SQL

I have the following table variable in SQL Server 2005: DECLARE @results TABLE (id int IDENTITY(1,1), customerId int, salesId int, score int, lastServiceDate datetime, PRIMARY KEY(id)); I need an efficient way to c...

SQL Server 2008 - Help writing simple INSERT Trigger

This is with Microsoft SQL Server 2008. I've got 2 tables, Employee and EmployeeResult and I'm trying to write a simple INSERT trigger on EmployeeResult that does this - each time an INSERT is done into EmployeeResult such as: (Jack, 200, Sales) (Jane, 300, Marketing) (John, 400, Engineering) It should look up for the Name, Department...

Slow MySQL inserts

I am using and working on software which uses MySQL as a backend engine (it can use others such as PostgreSQL or Oracle or SQLite, but this is the main application we are using). The software was design in such way that the binary data we want to access is kept as BLOBs in individual columns (each table has one BLOB column, other columns...

Portable JPA Batch / Bulk Insert

Hi, I just jumped on a feature written by someone else that seems slightly inefficient, but my knowledge of JPA isn't that good to find a portable solution that's not Hibernate specific. In a nutshell the Dao method called within a loop to insert each one of the new entities does a "entityManager.merge(object);". Isnt' there a way de...

Fork MySQL INSERT INTO (InnoDB)

Hello, I'm trying to insert about 500 million rows of garbage data into a database for testing. Right now I have a PHP script looping through a few SELECT/INSERT statements each inside a TRANSACTION -- clearly this isn't the best solution. The tables are InnoDB (row-level locking). I'm wondering if I (properly) fork the process, will ...