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

learn more… | top users | synonyms

-3
votes
1answer
42 views

how to insert into tables in sql server? [on hold]

I have a query to create "governorate table" like this: CREATE TABLE governorate ( ID int IDENTITY(1,1) PRIMARY KEY not null , name varchar(50) UNIQUE , ); then I want to insert data in ...
9
votes
2answers
12k views

What is the fastest way to insert large numbers of rows?

I have a database where I load files into a staging table, from this staging table i have 1-2 joins to resolve some foreign keys and then insert this rows into the final table (which has one partition ...
0
votes
0answers
33 views

Tuning a Postgres INSERT only database

I am designing a database which will have many inserts and selects, but no updates. Are there any considerations to take (in order to have high query performance) while knowing no tuple updates will ...
0
votes
1answer
607 views

INSERT take too much time

I have in my MySQL DB a few tables Most of the time, I'm only doing INSERT in my db. I have up to 4 connections to the DB, each one inserting into a different table. There cannot be two connections ...
2
votes
1answer
138 views

What are possible causes for consistently volatile INSERT performance in MySQL tables?

I have a Java program running on a VM that is sequentially feeding a queue of single row INSERTs through a single connection to a MySQL server on the same VM. The queue execution is not artificially ...
0
votes
1answer
37 views

Mysql How to insert a variable as field value in a table

I have created a variable named hash as a password hash. How can this variable be inserted a a field value in a table? hash = pbkdf2_sha256.encrypt("password", rounds=200000, salt_size=16) ...
2
votes
1answer
28 views

MySQL auto increment column increases after insertion error occurs

I was doing some insertion tests in my database and I realized that when the INSERT statement fails, due error 1452, causes the auto_increment value increase by 1. Even though, there wasn't any row ...
0
votes
2answers
52 views

Why do these concurrent MySQL inserts deadlock?

I am baffled by this deadlock: ------------------------ LATEST DETECTED DEADLOCK ------------------------ 150511 18:42:43 *** (1) TRANSACTION: TRANSACTION B8972CA4, ACTIVE 0 sec inserting mysql ...
0
votes
2answers
49 views

Insert query with a subquery

I want to insert somewhere around 400 rows into a table. All of the column values will be the same fixed value for most of the columns, with exception to one column which I want to pull from a fairly ...
0
votes
1answer
146 views

MYSQL: How to improve performance of inserting over 1M rows to a table with over 100M indexed rows

I have this mysql table: CREATE TABLE `codes` ( `code` bigint(11) unsigned NOT NULL, `allocation` int(11) NOT NULL DEFAULT '0', `used` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`code`), ...
1
vote
2answers
74 views

Merge faster than Insert

Are there any advantages/disadvantages of making use of a merge over a insert function? Can an insert statement make use of the `OUTPUT' Note: the ON clause for the merge is set to 1=0 (always ...
0
votes
0answers
10 views

inserting multiple rows with two input fields with same names [migrated]

HTML <tr> <td><input type="text" name="description"/></td> <td><input type="text" name="quantity" /></td> <td><input type="text" ...
3
votes
2answers
4k views

Copy from one MySQL table to another MySQL table of same database

I have around 40 million rows in a MySQL table and I want to copy this table to another table in same database. What is the most efficient way of doing this? How much time will it take (approx.)?
0
votes
0answers
10 views

Update or Insert on a Table based on a column value [migrated]

I have two tables BASE and DAILY as shown below: BASE Cust ID IP address 1 10.5.5.5 2 10.5.5.50 3 10.5.5.6 DAILY Cust ID IP address 1 10.5.5.5 2 10.5.5.70 ...
0
votes
2answers
48 views

MySQL - best practices/ how to speed up "update, else insert' queries? Insert + delete faster?

I'm running an ETL process and streaming data into a MySQL table. Now it is being written over a web connection (fairly fast one) -- so that can be a bottleneck. Anyway, it's a basic insert/ update ...
1
vote
1answer
54 views

Insert into table select * from table vs bulk insert

I just wanted to know that SQL Statement INSERT INTO TABLE1 SELECT * FROM TABLE2, will work same like bulk insert ? If no, Is there any way exclude index while inserting records. Process is inserting ...
3
votes
1answer
948 views

Insert Speeds for large batches

In my application, my INSERTs seem to be taking a major chunk of the time. I have a large number of objects in memory (~40-50,000) which i want to insert into a table. Lets take a sample table ...
1
vote
1answer
29 views

Using Identity Insert on a linked server

We have a database hosted in Microsoft Azure and using this database connection details I have created a linked server object in SSMS on our on-premise SQL box and I can insert into it as following ...
0
votes
1answer
139 views

Fastest way to insert data into mysql from csv

I have a dataset of 233,902,846 rows in a csv file. I want to load the data into mysql table. What is the most efficient way of transferring the data so that data insertion is the fastest. actually ...
1
vote
1answer
41 views

Insert/ Update Scalability (more records, continually longer lookups — solution?)

posted this before but never received a clear answer. I'm working on an ETL project and am basically feeding JSON records of "tickets" into a MySQL database. (actually come to think of it, may be ...
1
vote
2answers
242 views

How to duplicate related rows

Tables: Payments with auto-increment ID and one-to-many relationship to Projects such that one payment (say £10) has two records in Projects allocating the £10 between the projects. Now next month, ...
1
vote
1answer
53 views

trigger or check constraint insert values based upon existence of others

For simplicity (and since it captures the essence of my problem), suppose I have a table with data. CREATE TABLE my_practice_table ( my_id NUMBER(12), field_2 VARCHAR2(20), field_3 ...
0
votes
0answers
14 views

write data on multiple storageNodes in oracle NoSQL

I'm using oracle NoSQL on ubuntu (newbie to both) and created 3 storageNodes (with 3 RN on each) in one computer on different ports (5000,6000 and 7000) in a store named mystore. Now I need to write 1 ...
0
votes
1answer
33 views

Insert date values in a created table

I have created a table using the below query CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0) NOT NULL, START_DATE date NOT NULL, END_DATE date NOT NULL, JOB_ID varchar(10) NOT NULL, ...
0
votes
0answers
270 views

Proper usage of last_insert_id() in PHP procedure

I have a problem with performing sql query from php script. The query in sql looks like this: INSERT INTO `table1` VALUES (NULL, 'Blah', 'blah', 'blah', 'blah'); SET @lastID = LAST_INSERT_ID(); ...
1
vote
2answers
50 views

Speeding Inserts of longtext or longblob columns

i'm currently migrating a DB2 database to MySQL, using SQL WORKBENCH Tool It basically does a select from DB2 and Insert to DB2. It works fine, but on the tables with longblob or longtext columns ...
0
votes
1answer
23 views

Behaviour of Bulk Insert in pgsql or any Database

I'm using PostgreSQL 9.2.4. I'm working with multiple tables with large number of data. I have two tables Table_One which has one of the field with varchar(250) and Table_Two with one of the field ...
0
votes
2answers
489 views

Insert data in relation table and into data table with less query cost

I have a similar table layout: create table data ( id int identity primary key , value int not null); create table relation (id int identity primary key , ...
4
votes
4answers
6k views

How can I insert if key not exist with PostgreSQL?

I have a table: CREATE TABLE mytable (id SERIAL, name VARCHAR(10) PRIMARY KEY) Now I want to add names to this table, but only if they not exist in the table already, and in both cases return the ...
2
votes
2answers
116 views

How to handle too many inserts?

I have a database that is accessed from remote locations in the world with very long delays and poor transfer speeds. I currently transfer the data using a transaction since either all or no data ...
2
votes
1answer
35 views

Does Postgres preserve insertion order of records?

For example when I'm using query which returns record ids INSERT INTO projects(name) VALUES (name1), (name2), (name3) returning id; Which produce output: 1 2 3 Will this ids point to ...
40
votes
1answer
101k views

How to insert values into a table from a select query in PostgreSQL?

I have a table items (item_id serial, name varchar(10), item_group int) and a table items_ver (id serial, item_id int, name varchar(10), item_group int). Now I want to insert a row into items_ver ...
3
votes
2answers
433 views

Efficently Remove 90% of a table's data

I am working on a process to remove 90% of a table's data because only 10% is needed for testing. The best way I have found includes storing 10% of the table's rows into a temporary table. Current ...
4
votes
1answer
9k views

Fixing table structure to avoid `Error: duplicate key value violates unique constraint`

I have a table which is created this way: -- -- Table: #__content -- CREATE TABLE "jos_content" ( "id" serial NOT NULL, "asset_id" bigint DEFAULT 0 NOT NULL, ... "xreference" varchar(50) ...
0
votes
1answer
60 views

How to limit the range of an insert-update to only look at certain rows/ rows with field value: X?

I posted something similar before, but am still unsure of the technical implementation --- I'm so close to being there to the finished product. I have a table of tickets, and a stream of ticket ...
2
votes
0answers
44 views

Table queries locked during long insert SQL server

Everyday runs a sql job that loads data from bulk files and load them in auxiliary tables, to adapt and then copy to the destination table where applications read (and only read) the data. I am ...
0
votes
1answer
43 views

Delete index while query is running, is it possible?

I am currently importing Wikipedia pagelinks in my postgres database, and it takes forever (three days and still running). Is it possible to drop the primary key index while the inserts are still ...
2
votes
1answer
53 views

INSERT multiple values via join

I have three tables, representing two entities and a connection relationship. Each of the entity relations has an artificial surrogate key used for foreign key constraints in place of natural keys. ...
4
votes
1answer
86 views

Null Values in a CASE statement

I am playing around with some stuff in SSMS to learn a little more as I study for my 70-461 exam and I came across a little hangup. I am trying to create a table to play around with so I don't have to ...
0
votes
0answers
38 views

Better way to create an Events table?

I working on a medium sized PostgreSQL database with some schemas, each with some tables. In almost every schema there are tables that represent event tables, where something that has "happened to" ...
1
vote
1answer
59 views

How to insert the gathered dates into another table using INSERT SELECT in MySQL?

insert into rfdate (date) select adddate('1970-01-01',t4*10000 + t3*1000 + t2*100 + t1*10 + t0) selected_date from (select 0 t0 union select 1 union select 2 union select 3 union select 4 union select ...
0
votes
0answers
25 views

table not taking records sequencially [duplicate]

While inserting rows into a table in oracle 10g, the rows are not inserted in the order I am putting them, like for the following inserts: insert into emp values (1000, 'debjani', 30); insert into ...
0
votes
2answers
47 views

join value in a RETURNING which is not inserted

Im doing an insert from a query which joins two tables, then I want the new ID from the inserted row, and a field from the original row which is not involved in the insert.Is it possible? I get a ...
2
votes
3answers
1k views

Is inserting multiple queries takes same time as that of single query?

I have a requirement where I have to insert a lots of rows.For inserting we use like this insert into emp(name,age) values('abc',12); This will insert only one row.For inserting multiple rows we ...
0
votes
1answer
34 views

how to overcome these type of issues where null value inserted into primary key not null column in table

how to overcome these type of issues where null value inserted into primary key not null column in table
0
votes
1answer
94 views

Insert All Columns from one table into another table MYSQL

I am trying to insert multiple columns with their data from one table into another table, without a common column (i would expect a cross product in the result). I am not sure how that's possible, ...
2
votes
0answers
69 views

Combined UUID Index + AI PK Insert Performance

I posted this in stackoverflow but realised it probably belongs here instead. Imagine the following table: CREATE TABLE `orders` ( `ORDERID` int(11) unsigned NOT NULL AUTO_INCREMENT, ...
1
vote
2answers
162 views

Return the id after insert or select

I want to build a function which will insert an email if the email value doesn't exist in the table and return the email_id of the row. How can I do this? Also how can I return the id if the email was ...
1
vote
1answer
52 views

Inserting into related tables

I have a database setup with the following schema: CREATE TABLE siteInfo ( siteID SERIAL NOT NULL, siteName TEXT NOT NULL, siteHost TEXT ...
2
votes
1answer
92 views

I can't create relationship in my database sql server

I have designed a database for my website. It has 3 tables: user, topic and comment. A user has many topics (or articles) A topic (or article) has many comments A user has many comments I ...