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

learn more… | top users | synonyms (1)

-4
votes
0answers
31 views

Sql Code Insert Row [on hold]

Query Code: SELECT OOHEAD.OAWHLO, OOHEAD.OAORNO, OBPONR, OOHEAD.OACUNO, OOHEAD.OAORST,OBORQT, OOHEAD.OASMCD, OOHEAD.OAFRE1,OBLNAM FROM S066B45R.MVXCDTPROD.OOHEAD OOHEAD INNER JOIN S066B45R.MVXCDTPROD....
0
votes
1answer
45 views

Percona and MariaDB-10.0 ignoring not null on table fields

On the percona-5.6 and MariaDB-10.0 servers, the NOT NULL declared on table field are being ignored. I am able to leave fields declared as NOT NULL empty when inserting data and the servers are not ...
1
vote
1answer
57 views

Error code 1054: Unknown column when inserting data into a table [closed]

I have been trying to join data from two separate tables with distinct columns into a third table, but Error code 1054: Unknown Column 'Company' in field list keeps popping up. My current ...
0
votes
1answer
18 views

Convert timestamp type during INSERT

I have a table of raw data as timestamp with timezone, as well as other extraneous columns. I want to convert each timestamp to the interval difference between it and the earliest (smallest) timestamp ...
1
vote
2answers
83 views

INSERT and DELETE in single operation (moving from one table to other)

Stemming from this question, I am going to use that complex sort's results to decide which rows' data to move from one table to another. Though I have not yet tried it, I think there should be no ...
5
votes
2answers
7k views

Getting the “ORA-00911” error when I am trying to insert more than 1 row

Lets say I have the follow insert statements. INSERT INTO E_PRODUCT VALUES ('PCD2', 'PC Dual Core', 499, 22, 475, 'PC', NULL); INSERT INTO E_PRODUCT VALUES ('PCL4', 'Laptop PC', 599, 9, 225, 'PC', ...
-1
votes
0answers
51 views

Difference between Mysql table and histats analyzer

Explaining problem immediately. I have partly huge number of transactions (~ 30k per minute) and after putting analyzer system, weird issue comes up. say we have below psudo: Request received ...
0
votes
1answer
29 views

PHPMyAdmin very slow inserts

I was trying to insert around 70K records to mysql database through phpmyadmin and was shocked of how slow it is. It took around 5 hours to complete! Please find below the details of the table/...
1
vote
1answer
23 views

How to insert a record returned by a function into a table

I have a plpgsql function that takes one input parameter and returns multiple columns of data as a record. CREATE FUNCTION my_func( IN id bigint, OUT foo bigint, OUT bar double precision ...
1
vote
1answer
38 views

Using a subquery in place of a SELECT fieldname …or how to achieve the same result?

My goal is to get a collection of ID's from Table 1 based on a query, a collection of ID's from Table 2 based on a query, and insert a new record into Table 3 for each permutation. Basically, this: ...
0
votes
2answers
114 views

Inserting 500K records into SQL Server 2008 is taking 15s; how to optimize?

I have a SQL Server 2008 machine that is running backed by a SAN (not entirely certain of the SAN configuration). I've been noticing that some queries are slow to respond, so have been running some ...
1
vote
3answers
50 views

How do I prevent multiple row insert?

I set up a playground MySQL database for users and I'd like to prevent multiple row (large) inserts. That is, if there will be over N rows after INSERT operation, then raise an error and do not ...
1
vote
1answer
33 views

DELAYED User at MySQL

mysql> show processlist; | Id | User | Host | db | Command | Time | State | Info || 27098 | DELAYED | localhost | ...
3
votes
2answers
43 views

Insert if something changed other than specific column

I have a table with many columns but my snippet is simplified. I have the trigger shown below but how can I have it so that nothing is inserted if only the created_at column has changed? ALTER ...
0
votes
1answer
41 views

MySQL insert with sub select slow

We are using Python and LOAD DATA INFILE to load data from CSVs into our staging database. From staging we have sql scripts moving the data into our actual production database. LOAD DATA INFILE is ...
18
votes
4answers
2k views

How to limit maximum number of rows in a table to just 1

I have a configuration table in my SQL Server database and this table should only ever have one row. To help future developers understand this I'd like to prevent more than one row of data being added....
0
votes
0answers
15 views

On Duplicate Update Multiple Keys (not or) With And

I have friends table user_id_1 | user_id_2 | points 1 2 99 ADD UNIQUE (user_id_1, user_id_2) works perfectly, but i run this query; INSERT INTO friends (user_id_1,user_id_2) ...
0
votes
1answer
73 views

T-SQL insert with output expression [closed]

insert Table1 OUTPUT inserted.ID, s.[Id] INTO @Inserted select s.[Field1], s.[Field2], from @TableVariable s why is s.[Id] marked by red line ? Is it non-correct syntax to save value in @...
1
vote
0answers
37 views

INSERT MySQL stored procedure executes twice when it contains a select statement as well [closed]

I have a very simple MySQL stored procedure as shown below: BEGIN INSERT INTO listing_offers (lo_active, lo_amount, lo_amount_number, lo_contract_reference,lo_created, lo_currency, ...
0
votes
1answer
26 views

Mysql columns mutual exclusion

I want to create a table which has 2 columns that would only allow one of them to have value in the same row. I tried with CHECK constraint but it not working correctly Ex: SQL Fiddle schema ...
1
vote
1answer
24 views

Insert column name as value

Consider the following, in PostgreSQL: drop table test ; create table test (result1 text, red smallint, green smallint, blue smallint, results2 text) ; insert into test values ('red',1,2,3) ; I ...
0
votes
1answer
57 views

How to handle HUGE 16GB SQL file?

I've abc.sql file exported from MySQL Table. This abc.sql file is 16 GB in size with around 28 million insert statements. I'm looking for option to store it in SQL Server Database. Couple of ...
8
votes
1answer
20k views

On duplicate key do nothing

I am inserting into the following table using LuaSQL with PtokaX API. CREATE TABLE `requests` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `ctg` VARCHAR(15) NOT NULL, `msg` VARCHAR(...
2
votes
0answers
60 views

Insertion into postgres database stops (hangs) after table reaches a certain size without error

We are currently trying to insert a large amount of data, about 27 million records with 200 columns, into a single table in a postgres 9.4 database. (Yes it is probably better to refactor the table ...
1
vote
2answers
632 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 ...
0
votes
2answers
77 views

INSERT OR REPLACE INTO + SELECT as source in Oracle

I have two tables A and B. I want to insert B's content into table A. The issue is there's a row in B that already exists in A. I've searched and I found some answers talking about MERGE, but no ...
1
vote
1answer
55 views

What is the fastest way to insert data into MySQL memory table?

I need to insert 10M+ records into a MySQL memory table. A naive approach was to pipe records using shell, e.g. $ tail -10 ~/Desktop/test.sql INSERT INTO `test` (`a`, `b`) VALUES (4, 5); INSERT INTO ...
-2
votes
1answer
65 views

Cannot update nor insert data to datetime field [closed]

I was trying to insert data through one web application I am developing and I could not insert data, while I was troubleshooting what the problem is, I saw that I can not neither edit datetime field ...
4
votes
1answer
90 views

Persistent inserts in a UDF even if the function aborts

I have a rather complicated UDF (moves around a bunch of tables as well as creates a bunch of new ones) where multiple aborts may occur. Before every operation I would like to record the time when an ...
2
votes
2answers
50 views

Using Variables to contain column names for SQL Server Merge statemtns

I'm trying to automate the column list grab for a merge job, and running into a bit of a head scratcher. I don't want to have to manually type out all of the column names, and thought I may be able to ...
0
votes
1answer
17 views

A different number of AFTER INSERT trigger alarms in SQLite and SQL Server

I have trigger CREATE TRIGGER [Foo] AFTER INSERT ON [Bar] BEGIN UPDATE Log SET count = count + 1; END When i execute query insert into Bar (ColumnName) values ('SomeValue1'), ('SomeValue2'), (...
0
votes
2answers
65 views

Insert the same time, it is possible to happen?

Good evening. I have a doubt about inclusion in the database. A common example is a user account where the user names must be unique. In the following logic: User enters data into a form. Data are ...
23
votes
3answers
114k views

How do I insert a row which contains a foreign key?

Using PostgreSQL v9.1. I have the following tables: CREATE TABLE foo ( id BIGSERIAL NOT NULL UNIQUE PRIMARY KEY, type VARCHAR(60) NOT NULL UNIQUE ); CREATE TABLE bar ( id BIGSERIAL ...
0
votes
0answers
53 views

Very Very Veeery slow insert queries

I am writing here because I`ve already spent days reading tutorials, other topics in here, and trying different configurations. The project : Fashion website with ~200k products which should be ...
0
votes
1answer
45 views

INSERT and UPDATE in Trigger

I have created a trigger so I could insert every row in a backup table CREATE OR REPLACE TRIGGER xyz AFTER INSERT ON table_1 REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN INSERT INTO table_2 (...
3
votes
1answer
51 views

How to maintain trees and their roots in SQLite

I have a (SQLite) database with a table representing nodes in a forest (set of trees): create table "Node" ( "id" Text primary key, "parent" Text references "Node" ("id") -- parent node ...
0
votes
0answers
9 views

Inserting data from external PC faster than from localhost

I've been benchmarking the performance of a new virtual server in order to find out the best engine and database structure for my setup. Currently I am using python with mysql-connector both on the ...
1
vote
1answer
145 views

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

Is it possible to INSERT values into a PostgreSQL table from a SELECT statement and to use DEFAULT values for the columns that are null? In my case, the SELECT statement is selecting from JSON. In ...
3
votes
2answers
82 views

Inserting rows with WHERE condition

Structure 1 table named: scan 2 columns named: id, and date Problem I have two working queries, a SELECT and then an INSERT which I would like to merge together creating a INSERT where the ...
0
votes
1answer
40 views

Trigger with multiple inserts based on JSON data

I am using sqlite and have its json1 extension available. I have the following tables (reduced to a minimal example): -- table filled from external source, -- with only a little possible impact on ...
0
votes
0answers
15 views

Insert rows from another table while updating source table with IDs

I have this table structure table A: A.id (autogenerated) A.data table B B.id (autogenerated) B.A_id B.data B.anotherData There are some rows that were inserted into table B, without corresponding ...
1
vote
1answer
42 views

Is inserting into a table with a foreign key constraint slower than inserting without constraint?

When using MySQL (actually, Aurora), will inserting into a table with a foreign key constraint be slower than the same table without the constraint?
0
votes
2answers
126 views

How to insert numerous data into temporary table?

I'm building a program which generates a T-SQL query in following form: DECLARE @In TABLE (Col CHAR(20)) INSERT INTO @In VALUES value1, value2... value1000 GO INSERT INTO @In VALUES value1001, ...
0
votes
3answers
127 views

Is it possible to allow missing value inserts in mysql instead of requiring “NULL” in the query? [closed]

I am writing a script to insert values from a file into a mysql database. The script reads lines from the file and constructs insert queries from them. Sometimes particular columns are empty, so an ...
1
vote
1answer
34 views

INSERT INTO using the RETURNING values from another INSERT

I'd like to do something like this: INSERT INTO table2(name) INSERT INTO table1(name, address) VALUES ('me', 'home') RETURNING name; And then I would expect a new record in table2 with 'me' in ...
1
vote
1answer
34 views

Insert multiples rows/columns - PostgreSQL 9.2

I've got a table that has several columns, But I need to insert data into two columns of that table. I need to add data into those columns, from a select statement. Would it be something like: ...
-1
votes
1answer
38 views

Select and Insert for all data - Need help querying [closed]

At a first glance, this is my query INSERT INTO T2 SELECT T1.*, T3.DATETIME, T3.STATEID FROM T1 WHERE T3.DATETIME BETWEEN '01-NOV-15' AND SYSDATE LEFT OUTER JOIN T3 ON (T1....
0
votes
2answers
171 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 ...
0
votes
3answers
25 views

How to insert/combine values from multiple tables?

I have multiple tables (12 for each month) that have 3 columns each ("code", "test_name", "value") Example: January code | test_name | value 0001 name1 17 0002 name2 45 0005 ...
0
votes
1answer
65 views

postgresql insert from select query, plus static values

Referring to How to insert values into a table from a select query in PostgreSQL?, I would like to INSERT into a table rows from another, specified by a SELECT DISTINCT, plus some static values, ...