How are we doing? Please help us improve Stack Overflow. Take our short survey

Questions tagged [sql-insert]

The SQL INSERT statement allows you to insert a single or multiple rows into a table.

sql-insert
1,515 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
184 views

Postgres 9.6: Insert into view with on conflict

I have 2 tables both with unique constraints, 1 view that joins those 2 tables and an INSTEAD OF INSERT trigger that allows INSERT or UPDATE on the view. Everything works perfectly for regular INSERT ...
Daniel Worthington-Bodart's user avatar
5 votes
0 answers
1k views

How to avoid Aurora Postgres running out of memory for large insert into (select ...) query?

What I'm trying to do: I'm trying to move about 2m records from one table into another. To do this, I'm doing an insert statement which is fed by a select query. insert into my_table ( select a, b, ...
I was in the neighborhood's user avatar
5 votes
1 answer
882 views

How to insert variable into Database from view in MVC

I'm looking for a way to import a load of variables, calculated in a foreach loop, into my database. I'm building an application that extracts values from plain text (.txt files). In the example below ...
Jasper Zondervan's user avatar
5 votes
2 answers
4k views

Insert new record via Liquibase with foreign key

I am using a Liquibase insert to add two rows to the database and link them via a foreign-key as follow: <changeSet id="1.0.1" author="x"> <insert tableName="TABLE1"> &...
Christophe's user avatar
4 votes
0 answers
70 views

MySQL INSERT INTO skips nullability of column

Let's say we have table defined as: CREATE TABLE tab(col VARCHAR(100), col2 INT); Both columns are nullable. ALTER TABLE tab ALTER COLUMN col2 DROP DEFAULT; was applied on column col2. Quick check:...
Lukasz Szozda's user avatar
4 votes
4 answers
2k views

INSERT INTO fails with node-mysql - variable is always NULL

I am using MySql with node.js I have this query and it not works, temp1 in MySQL is alwayls NULL: var queryTemp1 = { tid: '1', temp: temp1, timestamp: myDate }; con.query('INSERT INTO temps SET ?', ...
piotr's user avatar
  • 43
4 votes
3 answers
2k views

Dependent SERIAL column in PostgreSQL

I want to get this result in my table contacts: |contact_id | user_id | user_contact_id | +-----------+------------------+----------------------+ | 1 | 1 | ...
CodeRows's user avatar
  • 973
3 votes
1 answer
122 views

PosgreSQL INSERT ON CONFLICT sometimes does not work with partial index

Example: CREATE TABLE IF NOT EXISTS test ( type character varying, id integer ); CREATE UNIQUE INDEX IF NOT EXISTS uniq_id_test ON test USING btree (type, id) WHERE (type = 'Test')...
miroshnik's user avatar
  • 163
3 votes
0 answers
835 views

athena insert and hive format error for HiveIgnoreKeyTextOutputFormat

Before the question/issue, here's the setup: Table 1 CREATE EXTERNAL TABLE `table1`( `mac_address` string, `node` string, `wave_found` string, `wave_data` string, `calc_dt` string, `...
nate's user avatar
  • 470
3 votes
1 answer
2k views

Execute sql queries gcloud command line

I have a SQL instance which has a DB into which I will be importing some data using gcloud sql import .... Thereafter, I want to run a list of INSERT queries to insert data into tables in that DB. ...
Arjun Mehta's user avatar
3 votes
0 answers
46 views

mySql Insert X Select Y fails while Select Y succeeds and Insert X "literal Y" succeeds as well

mySql 5.6 - OK: Select Extract(YEAR_MONTH FROM STR_TO_DATE('09/06/2018 Thu',... OK: Insert into T ...literal result of above select FAILS: Insert into T Select Extract(YEAR_MONTH FROM STR_TO_DATE ... ...
Citizentools's user avatar
3 votes
0 answers
837 views

Issues in SYSTEM_VERSIONING OFF - Insert record failed in SQL Server

I'm having a System Versioned Temporal Table namely [dbo].[Contact], for development purpose I tried to seed some old dated data. The table contains GENERATED ALWAYS column. This question is a Child ...
B.Balamanigandan's user avatar
3 votes
1 answer
8k views

Using a MySQL function to insert records into a table

I am trying to use a MySQL function to insert records to a permanent table. My SQL function code is similar to this:- delimiter // create function fn_eval ( a varchar(36), b int, ...
Annie's user avatar
  • 135
3 votes
1 answer
725 views

What is the exact behaviour of an INSERT IGNORE.... SELECT.... ORDER BY... LIMIT... in MySql?

In MySql 5.6 I have a query similar to the following: INSERT IGNORE INTO TABLE_1 (field_a,field_b) SELECT field_a,field_b FROM TABLE_2 WHERE ... ORDER BY field_a LIMIT 0,10 TABLE_1 is a temporary ...
clami219's user avatar
  • 3,028
2 votes
0 answers
122 views

How to improve SQL Server 'INSERT INTO' query runtime?

I have about 24 million rows of data which I need to insert into a table with a standardised format. My insert query is as follows: SELECT ... INTO TABLE2 FROM TABLE1 This is usually how I perform ...
Ethan Mark's user avatar
2 votes
0 answers
22 views

How to avoid the Runtime Exception error when multiple device ids are inserted at the same time in Apache IoTDB?

During the process of batch storage into Apache IoTDB, the following error is occasionally reported, and there is no abnormality in the data inserted. I have verified the data, and found that if two ...
Cecilia Wong's user avatar
2 votes
0 answers
167 views

Why Python dataframe to sql does not work

I have a pandas dataframe and am trying to add it to a SQL table on a SQL server. I made the connection to the SQL server with sqlalchemy. I try it with df.to_sql(). But I get an error message that I ...
FabianxS's user avatar
2 votes
1 answer
719 views

MySQL secure-file-priv=""

I have next problem: I want to insert in a table an image (LONGBLOB). First of all, I successfully inserted the image from C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads (secure-file-priv = "C:...
John Jwick's user avatar
2 votes
0 answers
233 views

Is there a way to get the row and column where the INSERT-Statement failed in PostgreSQL?

I'm trying to insert around 15000 rows with 200 columns in one batch into a table in PostgreSQL (with TimescaleDB extension) via Python by using the psycopg2 library. Some of the values I want to ...
Gustav Gamer's user avatar
2 votes
2 answers
2k views

Check if a record already exists in SQL Server table before inserting

I have an Excel table with 5 columns and 3 rows with data. Every time the data changes it is uploaded to DB. Below is my code to send data from the Excel table to the existing table in SQL Server. The ...
Ania Pirc's user avatar
2 votes
1 answer
146 views

ADODB EXCEL SQL CopyFromRecordset to slow

I use VBA and ADODB Connection in Excel to realize VLOOKUP with SQL in attached code: The Line "ThisWorkbook.Worksheets("result").Range("A1").CopyFromRecordset rs" takes ...
Michael  Oelsner's user avatar
2 votes
1 answer
2k views

Unable to insert NULL values to a NOT NULL date field after upgrading from MySQL 5.7 to MySQL 8

I upgraded from MySQL 5.7.26 to 8.0.20. One of the tables have not null column with TIMESTAMP data type with a default value as CURRENT_TIMESTAMP. On 5.7.26 , if an insert statement like the following ...
Insider58's user avatar
2 votes
1 answer
363 views

MYSQL INSERT not adding values to table

I am using the INSERT function to try and add new values to a table. While there is no error when I run the query, it is not showing the new attributes added to the table. I have no idea why. I also ...
Scott's user avatar
  • 33
2 votes
1 answer
1k views

Stored Procedure with if else statement in PostgreSQL

I'm trying to find the best way to make a 'like' button on my application. I would like to hit the same endpoint and have a stored procedure take care of the logic. This is what I have so far, but it ...
PPS's user avatar
  • 69
2 votes
1 answer
303 views

PL/SQL: How to insert depending on column value

I'm a novice at PL/SQL. I have attempted various approaches to use a Cursor to insert into a temp table depending on whether or not the value already exists in the temp table. I either get too many ...
vzmon1's user avatar
  • 69
2 votes
0 answers
101 views

import data from source db to target db using flask sqlalchemy

I want to fetch data from one source database and insert it into my targeted database using flask SQL alchemy Database_connection app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:root@...
Jayadeepu Dadi's user avatar
2 votes
2 answers
5k views

Oracle SQL Trigger: After Update, Insert Rows into Another Table

I am trying to write a trigger on one table that is triggered when the quantity in stock = 0. It will then add a row to another table with the product_id and store_id to indicate that item needs to be ...
transcenden's user avatar
2 votes
1 answer
159 views

How to add a series of data in a table?

I need to add a series of data from 0 to 1000 in a column of a table in LibreOffice Base and I would like to find a way with a SQL command instead to insert all 1000 one by one. Is it possible to do ...
Luca DEL PARTITA's user avatar
2 votes
0 answers
594 views

PHP MySQL Set inserted value as PHP variable after using INSERT SELECT

I am trying to figure out how to pass the inserted value which in this case would be a status value as a PHP variable. This is my query for inserting a new row into the book table (PHP/MySQL). $sql =...
Haizad Annuar's user avatar
2 votes
2 answers
3k views

Inserting Special Characters in SQL insert query

The sql statement I am trying to execute is INSERT INTO Scanners (Character) VALUES ('~') The characters I would like to insert are: {,}, [, ^ , & , ~, ` , : , ;. But it says syntax error. Any ...
user avatar
2 votes
1 answer
414 views

Compute field - insert into m2m relation table

In model project.task I create many2many field x_something linked to another model. So, in this relation table there is a field id from project.task and another model. And in another field of ...
LukaszK's user avatar
  • 181
2 votes
1 answer
10k views

Insert multiple columns and rows into SQL Server with node js

I'm trying to to make a script that reads from a nosql and inserts into a SQL Server database. That said I'm reading collections dynamically, so I need something to do things like var columns = [ 1,...
Carlos Eduardo Teixeira's user avatar
2 votes
1 answer
2k views

INSERT INTO inserting 0 rows

In my Postgresql database, I'm trying to get the coordinates (lat, lon) from a table planet_osm_nodes, where the ids are equal to those in edges2, and insert these into two columns in edges2. ...
Merlin's user avatar
  • 43
2 votes
0 answers
5k views

org.postgresql.util.PSQLException: ERROR: column is of type bit but expression is of type character varying

PostgreSQL database: one table has a field of data_type bit with a character_maximum_length of 1. When inserting data I get the error from the title. I am using liquibase to do the insert <column ...
werwuifi's user avatar
  • 379
2 votes
1 answer
29 views

how to use one insert command with different data types

I'm working on a web application for a subject my question is: I have a file to use the insert command but I have different thing I want to insert, I want to insert users in a table and schedule ...
Hackdoor145's user avatar
2 votes
1 answer
840 views

MS-Access : SQL JOIN and INSERT INTO with WHERE slow

Long story short: A SELECT query with an INNER JOIN of two tables is inserted into a new table via INSERT INTO. While this query finishes within 20 seconds, adding a WHERE condition in the SELECT ...
HeXor's user avatar
  • 1,105
2 votes
0 answers
51 views

How can I insert a bunch of records into MySQL from a file

How can I insert a bunch of records into MySQL from a file I'm writing this app for a library with java and JDBC I have this so far. the program is capable to export a file with a lot of books, I ...
Iván Antonio Moya López's user avatar
2 votes
1 answer
1k views

SQL Server : trigger update column of table after other table insert or update a record

I have 2 tables, ShareButton and SharePage. ShareButton table: +----+---------------+---------------+ | ID | Name | TotalShare | +----+---------------+---------------+ | 1 | Facebook ...
P. Pogba's user avatar
  • 175
2 votes
0 answers
155 views

self split insert in oracle interval partition

i have very strange problem. i have some insert into interval partition table. The insert take a long time - but the interesting thing is that after some time that it's running - it's just stop it's ...
user2671057's user avatar
  • 1,471
2 votes
0 answers
1k views

PostgreSQL performance using libpq/libpqtypes - multi line inserts

I am writing an application to read realtime data in an embedded environment and chuck it into a PostgreSQL 9.6 database. The data consists of a header with meta data including a timestamp and 200 ...
SteamedUp's user avatar
  • 131
2 votes
0 answers
491 views

Atomic read and write in one query in Oracle

I have an app that requires a single instance of a task to be run. In order to check whether a current instance of the task is already running, i check the status of the task. If the task has a ...
jav's user avatar
  • 21
2 votes
0 answers
1k views

Not warn INSERT IGNORE python

Is there any way to not raise any warning when using INSERT IGNORE ? I am getting this warning from my python script and I would like not to show it since this warning is expected (that is why I use ...
user1618465's user avatar
  • 1,871
2 votes
0 answers
618 views

Insert row based on existing row and update the existing row after (Postgres)

I have a table "tablea" with column "a" and "b" In the table is a row with a = 1 and b = 3 Now I want to produce a Postgres SQL query which inserts a new row with a=x and b = 3, where x is some ...
Eldamir's user avatar
  • 10.1k
2 votes
1 answer
174 views

conversion error double to integer vb.net - advantage database server

I'm getting this error when my program inserts CSV files into Advantage database Server, so my primitive solution was to insert lines parameterized: Private Sub AddParameters(ByRef db As DBUmgebung....
Sparkm4n's user avatar
  • 644
2 votes
1 answer
297 views

Parse rows of data from string and insert into database

I am new to PHP apologize if this is an unworldly question. I am receiving a packet of data with dynamic length on the tcp/ip socket. The packet looks like this: Palace1,radio,location1,location2,...
Crazy Engineer's user avatar
2 votes
0 answers
179 views

SQL Server 2008: Sql Insert/Update into another table using insertion IDs output from another table

I have a procedure for insert in multiple dependent tables (update in case record exist). I have input parameters as comma separated string which I am reading in table. After 1st insertion I am ...
Petal Ridz's user avatar
2 votes
1 answer
51 views

How to preserve relationship between rows inserted to table and source SELECT clause?

I have following code: DECLARE @NewTenant INT = ...; DECLARE @TemplateTenant INT = ...; CREATE TABLE FooTable(FooID INT PRIMARY KEY IDENTITY(1,1), TenantID INT REFERENCES ..., SomeData XML) INSERT ...
Ginden's user avatar
  • 5,238
2 votes
2 answers
152 views

Calling WCF service in Jquery throwing errors

I want to insert data into sql server calling WCF in Jquery. I dont know why I am getting an error which is very dificult to trace out. I am giving the code below Please help . 1) IService.cs [...
user3589162's user avatar
2 votes
0 answers
660 views

Python SQLAlchemy - large insert into postgres table hangs

I've got a script that is attempting to insert a large number of rows into a postgresql table. When I say large, I mean up to 200,000. I'm inserting data from python using sql alchemy. Each row is ...
neelshiv's user avatar
  • 6,245

1
2 3 4 5
31