A core statement in SQL that does what it says on the tin: inserts data into a table.

learn more… | top users | synonyms

0
votes
1answer
25 views

Every “INSERT” query check a combination of column's records

Unfortunately, my mind has stacked right now and i would like to design a really simple DB schema. What i want? In a simple table, for instance Table1, there are two different columns, Series and ...
0
votes
0answers
18 views

Split data from a column into multiple rows and split data from other column into new column in MySQL

I want split data's separated by comma(,) from a column into multiple rows and also with this I want split data's from other column into multiple new columns. Finally result will insert into new ...
-1
votes
1answer
49 views

What is the optimized way to fill table values based on it's previous columns values and from other table column values?

CREATE TABLE TEST2 ( RowID INT IDENTITY(1,1), Ratio INT ) CREATE TABLE TEST ( RowID INT IDENTITY(1,1), Col1 INT, Col2 INT, Col3 INT ) Now, I want to insert values in table ...
-1
votes
0answers
41 views

insert performance of Mysql InnoDB vs Mongodb

I often heared that Mongodb has a better performance than mysql while mysql has more consistence than Mongodb. Then I did a experiment using the following python code based on MySQL-python and ...
0
votes
2answers
91 views

Trigger to compare inserted value with value from another table

I have two tables: Stockitem (serialno, qty) serialno is the primary key and Order(serialno,orderno,qty) orderno and serialno are the primary keys. I want to create a trigger in order to ensure ...
3
votes
3answers
74 views

SELECT + INSERT or INSERT alone

I have an application where several devices send data every second to my server. On the database I have a table with the devices and another table with the data sent every second. The first time a ...
0
votes
1answer
47 views

MySQL Using a trigger to update quantity on another table if part is used

I am new to triggers but want to know how I can use one in my database. I have created a table for a maintenance log, a parts inventory, and a parts_used junction table. When maintenance is carried ...
-2
votes
2answers
74 views

Change IDENTITY_INSERT to ON in SQL server [duplicate]

How can I insert an ID into an identity column in SQL Server? I'll make a special item into my table and I will quickly detect that item by the ID. So because all other ID's are bigger or equal to ...
5
votes
1answer
57 views

Are there practical scenarios where inserts + deletes are faster than updates? (SQL Server)

I'm just wondering if there are common scenarios where an insert/ delete combination is faster than an update else insert function. Here is my specific example. I have to update a database with ...
0
votes
1answer
34 views

Remotely inserting 3.5m records mysql

I need to remotely insert 3.5 million rows to my amazon rds. Currently my data is in an access database, for which I will use bullzip, access to mysql to create dump files. I have created my schema on ...
4
votes
1answer
39 views

Measure Performance for INSERT, UPDATE and DELETE commands on DB2

I have a DB2 database with a table for daily transactions, which is cleared to a history table at the end of the day, every day. I insert rows to this table via java-JDBC INSERT commands and they ...
0
votes
0answers
40 views

I'm sure there's a better way than this INSERT

I have 2 tables: logs and relations. Logs' field have something like this: id (serial), mid, rid, value, insert_date Sample logs: 1001, 21, 1, "-94.420307", "2015-12-10 18:00:01" 1002, 21, 2, ...
2
votes
1answer
81 views

Fill Database With Recursive Factorial Function

I want to calculate table's all of the rows's factorials value. And then i want to insert to each row's factorial value in table. so that i create table like as below: TABLE:FACTORIALS ...
0
votes
1answer
43 views

Insert query optimization

Need your help optimising an insert query. I have two tables in my MySQL DB. I will be inserting into Table1. Information will be retreived in Table2. Table 2 contains a couple of million records. ...
0
votes
1answer
74 views

Vertica INSERT speed highly depends on server load

I faced a problem with very slow INSERTs in Vertica DB. I made such test: create empty table with no projections and start inserting in it in batch, using > INSERT INTO table SELECT 111,222,333 ...
0
votes
0answers
14 views

PostgreSQL - Error: duplicate key value violates unique constraint [duplicate]

I try to insert a record into following table: CREATE TABLE web_structure( id serial NOT NULL, label character varying(255), name character varying(255) NOT NULL, frompage integer, topage ...
0
votes
1answer
67 views

MySQL trigger if new value is not equal to varchar

StackExchange, I'm trying to create a trigger in MySQL (before insert) that gives an error if the new value of "sifra" is not S, P, K, A or Z, but it I'm getting an error even if the said criteria is ...
4
votes
1answer
80 views

Generate fake data for several tables with relationships

I have 3 tables where I want to generate fake data in UsersCategoryLink. How can I insert in the table UserCategoryLink the column UserID with random users from the table User and a random id from ...
3
votes
1answer
151 views

How to insert/update millions of rows inside a sql server table(s) in an effective way?

Often in my job I have to create a procedure inside SQL Server that will process millions of data rows, save them into a temp table (staging table) and finally save them into a table (s) in a ...
0
votes
0answers
25 views

Any risks to pure inserts + delete duplicates, instead of insert/ update for SQL Server?

I saw a related question but it was more of the how vs. the why. I'm wondering in SQL Server why one would attempt an "insert/ update" with incoming data ... instead of just running pure inserts ... ...
1
vote
1answer
136 views

INSERT don't work with NOT NULL but UPDATE does, why?

I have this table definition: CREATE TABLE `media` ( `id` int(11) NOT NULL AUTO_INCREMENT, `brands_id` int(11) DEFAULT NULL, `media_type` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, ...
0
votes
0answers
21 views

Best way to generate backups with 'INSERT ON DUPLICATE KEY UPDATE'

I have been using HeidiSQL to generate MySQL backups using 'REPLACE INTO' however have recently come across the problem this causes with foreign keys & have been told using to use 'INSERT ON ...
2
votes
2answers
183 views

MERGE command in SQL Server 2005

I have been trying to develop a MERGE in SQL Server 2005. It does not have all features yet, because I have been struggling in "how to put the merge logic WORKING AS A SET, rather than rows". ...
1
vote
1answer
68 views

How to measure I/O contention after adding calculated fields on indexed views to a table in SQL Server?

I have successfully added several calculated fields to different tables, for example: ALTER TABLE dbo.tblBGiftVoucherItem ADD isUsGift AS CAST( ( ISNULL( CASE WHEN ...
0
votes
0answers
32 views

Proper way to insert data into multiple tables

I am wondering about the proper way of inserting related data into a database. As an example please refer to the following EER diagram: I have data for this model stored in multiple CSV files. The ...
8
votes
3answers
162 views

Poor cardinality estimate disqualifies INSERT from minimal logging?

Why is the second INSERT statement ~5x slower than the first? From the amount of log data generated, I think that the second is not qualifying for minimal logging. However, the documentation in the ...
0
votes
3answers
512 views

Lock mysql table to prevent select and insert at the same time

I know this question has been asked earlier and I have also read the documentation. But I guess I'm stupid not understand. I have a code that inserts a row and the row should be unique in several ...
1
vote
1answer
363 views

how to insert a list of varchar values, into a single column table?

In SQL Server 2005: CREATE TABLE __RADHE ( itemNo varchar(10) not null primary key clustered ); GO INSERT INTO __RADHE ??? '34926840', '34927020', '34927202', '34927384', '34927566', ...
0
votes
0answers
302 views

Insert string content into a blob in DB2 database using a simple SQL query

I am having trouble inserting in a BLOB field some text content (in fact it's an XML, I know there are field-types more suited than BLOB for this type of content, but I simply can't change it). I ...
0
votes
0answers
36 views

How to improve the slow performance with Insert operations in SQL Server 2005?

Suddenly our server started to have a bad performance, after trace the error, I identified that the inserts are the problem, this seems a know bug: https://support.microsoft.com/en-us/kb/940545 (The ...
0
votes
2answers
93 views

INSERT in a remote server is far too slow, how to speed it up?

I need to load 480.000 rows into a remote database. The database can't be accessed locally, it's an Azure WebApp, so i can't load the SQL statements on the server. I was wondering if there is a way to ...
1
vote
1answer
218 views

mySql while loop ending after a insert

I have a stored procedure that is looping through a result set from a select statement. Inside of the loop there is a if statement that has two insert statements. When one of those insert statements ...
4
votes
2answers
262 views

What causes large INSERT to slow down and disk usage to explode?

I have a table of about 3.1 million rows with the following definition and indexes: CREATE TABLE digiroad_liikenne_elementti ( ogc_fid serial NOT NULL, wkb_geometry geometry(Geometry,4258), ...
1
vote
1answer
113 views

Count distinct values of a column and insert them to another table

So, I have a database for logs and statistics. But, the amount of data sent is too high, so I was thinking of grouping the data into another table. So the structure of the original Database is: ID ...
0
votes
1answer
42 views

INSERT from SELECT using a CURSOR

I have a table that looks like this: +====================================================+ | aid | uid | eid | name | dob | paid | ...
0
votes
1answer
37 views

Insert but Don't Commit MySql

I am pretty new to MySql and Databases, and I was wondering in python sometimes I forgot to commit after an insert, and then when I do then next insert and commit that one the, auto-incrementing id ...
-1
votes
1answer
104 views

How can I generate a script to choose only top 10 items from each table in SQL database?

I know how to generate scripts that would contain insert queries of all records in all tables. But how can I limit this to top 10 records only from each table?I can select "Data Only" when generating ...
2
votes
1answer
43 views

Create one row for every user in a Postgres table

I have a bunch of rows of users in a users table, for example: | id | name | |----|-------| | 1 | Chris | | 2 | Max | | 3 | Steve | For each one of these users, I'd like to create a row in ...
0
votes
1answer
25 views

How to make a mysql statement for sent log

I have a table called "make_sent_log" CREATE TABLE IF NOT EXISTS `make_sent_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `transaction_id` varchar(255) NOT NULL, `total_base` int(11) NOT ...
3
votes
2answers
1k views

INSERT… ON DUPLICATE KEY UPDATE not working as I expect

I have a table called "Example" CREATE TABLE IF NOT EXISTS `example` ( `id` int(11) NOT NULL AUTO_INCREMENT, `a` int(11) NOT NULL, `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY ...
1
vote
0answers
70 views

Unable to insert explicit value in table due to IDENTITY_INSERT is ON Error

I am trying to insert explicit values in one of my Real time Audit Production database. There are more than 80 columns, I have just taken here 5 columns. I am writing syntax is as below: use ...
0
votes
1answer
98 views

Increase SQL Server Performance

I have a fairly simple SQL Server 2014 Standard database with one main table. Here's the workload: I insert a row, do a few updates to it (up to 5 updates), and move on. I always update recent rows. ...
1
vote
1answer
45 views

Nightly Excel Spreadheet import into mssql database

I am currently working with a nightly import that I need to create, but am not sure what the best route would be to update/insert into the current table. This is all done in MS SQL Server 2012 and ...
1
vote
1answer
24 views

How can I insert procedure results from server 1 into table in server 2?

The goal is to link our website to the database. The database the website will connect to will be different then our production db. In fact, a separate instance of SQL. How can this be structure to ...
0
votes
1answer
116 views

Mysql 5.5 to Mysql 5.6 upgrade Insert query is breaking

Assume column with the following definition product_id INT NULL NO_DEFAULT product_id_nn INT NOT NULL NO_DEFAULT and query insert into table (product_id,product_id_nn) values ...
1
vote
2answers
68 views

Create rows when selected rows exist

I haven't spent much time with SQL Server, and I can't seem to figure something out. I have 3 tables; user, usergroup, group. usergroup is a table that contains both a group id and a user id, where ...
1
vote
1answer
110 views

MySQL: is it more efficient to query for duplicate row or insert(update) on duplicate?

Just curious on resource efficiency. If I have a list of inserts that need to be accomplished repeatedly which may contain duplicates (there is no way around this, the API I have to work with sucks), ...
1
vote
0answers
83 views

Improve postgreql insert performance when compared to Oracle. Low memory utilization by Postgresql threads

I am trying to improve the performance of Postgresql (version 9.2.3) inserts for a simple table with 1 bigint, 1 varchar, 1 float and 2 time stamps. A simple replication of my JDBC program is ...
0
votes
1answer
168 views

How to insert all the dates in a date range into Oracle database?

For instance, The date range is from 26th Jul to 1st Aug, that is 26th Jul, 27th Jul, 28th Jul, 29th Jul, 30th Jul, 31th Jul and 1st Aug How can I construct a function (of course, I need to ...
0
votes
1answer
141 views

Multi-threaded inserts vs serial

I have a large database application on SQL Server 2012 Standard Edition which receives data from hardware in chunks of 500-1000 (100 byte) rows every few seconds through a stored procedure. Would a ...