Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
1answer
41 views

What is the best way to check if a value in a table has changed when writing to a database?

Let me provide you with an example. Let's say I have an html_tag with two columns, tag_type and tag_value For example, let's say I have a record with the value "link" under thetag_type field and "...
2
votes
2answers
51 views

Insert/update data into relational database tables only after administrator approval - how to approach it?

I'm building a relational database that holds 21 tables, which is connected to my website application through PHP. The website has search functionality which allows users to search this database. ...
0
votes
0answers
40 views

How to copy non partitioned table data to partitioned table

I have a table (a) with 8 million rows and an index but the query is very slow. So I created a partitioned table (b). How to copy data from the non-partitioned table to the partitioned one in ...
0
votes
1answer
18 views

Need some insights on 'index_page' variables in Innodb_Metrics Table

I was experimenting with page-split behaviour for sequencial vs random ordered inserts in Mysql,Innodb. For sequencial Inserts I got: index_page_splits: 3199 index_page_merge_attempts: 0 ...
-2
votes
2answers
48 views

How to UPDATE along with INSERT INTO SELECT [closed]

I added some entries from table2 to table1 as INSERT INTO table1 (title) SELECT title from table2 WHERE ... how can I UPDATE table2 for the SELECTed or INSERTed entries as UPDATE table2 SET status='...
0
votes
1answer
23 views

How to accomplish such insert-or-update strategy?

Programming stored procedures isn't my strongest point when it comes to programming, but I'm trying to get better. I've stumbled upon a business requirement that's kind of hard for me and I was ...
0
votes
0answers
10 views

How works the flash recovery area

Im working with QGIS and Im trying to save a Mapinfo map to Oracle Spatial. The map file is around 1GB and has 700k road segment. The issue is when copy the segements from the source map to the db ...
0
votes
1answer
21 views

In which context does a procedure run when called from another context?

Envisage: use databaseA; go exec databaseB.dbo.spProcedure(); go Does the procedure execute against databaseA - the context from which it is called, or databaseB - the context in which it exists? ...
1
vote
0answers
20 views

How to insert static strings appended to incrementing numbers into database column? [closed]

I'm pretty new to SQL so not too familiar with queries outside normal SELECT, INSERT, etc. But I'd like to pre-populate a column with values of the form FBxx (i.e. FB00, FB01, FB02, FB03..., FBFE, ...
0
votes
1answer
24 views

Get result from select exists, execute insert query based on the response of it

I have to insert unique value for a row but has to put check on 3 columns collectively ((unique value(col1 && col2 && col3) == true) I found a solution here it is query = select ...
1
vote
1answer
51 views

Insert Trigger to a Linked Server error

I created an insert trigger in a table that will fire when an insert/update/delete is made. The trigger is supposed to send information about the query that fired it, but every time it fires, the ...
0
votes
0answers
30 views

Why this trigger is not inserting records?

Here are my 3 tables. Passenger(Passengerid,insuranceid) Passenger_service(passengerid,serviceid) service(serviceid,hotel_insurance_id) Whenever there is a record inserted in passenger table along ...
1
vote
1answer
53 views

How to perform multiple inserts into postgresql database in one query

I have an orders, recipient and items tables. I want to insert data into each of these tables based on the response from the previous query. insert into recipient(name, address) values(name, address)...
0
votes
1answer
34 views

INSERT INTO statement with select

I am trying to insert a new record into a table, but only if another record of the same table meets some conditions. Sadly it does not work I alwys get the following error: ERROR: duplicate key value ...
0
votes
2answers
43 views

ORACLE Table insertion

I want to insert data into below table, but I got an error. How do I solve this? CREATE OR REPLACE TYPE TEST_TYP FORCE IS OBJECT ("id" VARCHAR(5000 NULL) NOT FINAL; CREATE OR REPLACE TYPE TEST_TAB ...
0
votes
1answer
34 views

How to use the result of an insert as foreign key in another insert?

I have a temporary table with lots of data. I want to populate two persistent tables with excerpts of that data, preferably in one go. Problem: after insert on tableA, I want to reuse the generated ...
0
votes
1answer
46 views

MySQL: Trying to “normalize” data using MySQL to help

I inherited a spreadsheet with 1600+ records, which I simply inserted into a single table (mapping) in MySQL. I'd like to use the power of MySQL to help me do some "normalization", à la the MySQL ...
0
votes
1answer
55 views

How can you insert data into a ARRAY column on a Snowflake table using SQL?

I am having difficultly finding documentation on how to insert data into an ARRAY column type using SQL on a Snowflake table. Snowflake Documentation: https://docs.snowflake.net/manuals/sql-reference/...
0
votes
2answers
21 views

How do I end function when X

so my function looks like this: create or replace function insert_stuff(a1 text, a2 text, a3 int) returns table (id_i int, id_j int) as $$ begin return query with i1(id1) as select insert_here(a1,a2)...
0
votes
0answers
14 views

Get the syntax that fired an insert trigger [duplicate]

Is there a way for an insert trigger to get the line that caused it to activate?
0
votes
1answer
39 views

How can I subtract two row's values within same column and then insert random values between the two rows if the difference > 30s?

Here is my question: This is a table in SQL Server 2012: ,then I should calculate the differences of WRTime between the adjacent two columns. If the difference > 30s, I should insert some random ...
2
votes
1answer
90 views

Error while inserting into array of timestamps

Im using postgres 10.1 and the Datestyle config is the following DateStyle ----------- ISO, MDY Im having this error ERROR: date/time field value out of range: "1535673858" Hint: Perhaps you ...
2
votes
2answers
502 views

Inserts in MySQL 8 are slower than Inserts in MySQL 5.7

I've started to use MySQL 8 (8.0.12), and I'm realizing that the "inserts" are slower in this version than MySQL 5.6 or MySQL 5.7. It doesn't matter if the table is MyISAM or InnoDB, with just one "...
0
votes
2answers
66 views

MySQL 5.1 - long running select locking the table and not allowing inserts

Platform - MySQL 5.1, MyISAM engine We reached max on int (id, auto increment) in our Prod system. Changed the type to BigInt. Even since this change was made, long running selects are locking the ...
2
votes
0answers
82 views

SQL Server: INSERT-SELECT Statement occasionally fails silently and works upon re-run

We have a batch import process that BULK INSERTs raw data into staging tables, does some data mapping, and then pushes it to another database for validation. The procedure where my issue occurs is ...
3
votes
0answers
61 views

Where is Newid(), Rand(), and Sysutcdatetime() new value per query vs. row behavior documented? [duplicate]

Within a single query, all current time functions like sysutcdatetime() return a single point in time that is re-used throughout the query for each instance (e.g. of sysutcdatetime()) no matter how ...
0
votes
3answers
217 views

Insert Values Into Table, Putting Duplicates In Another Table

So I posted this question yesterday. Some of the responses I got were helpful, however it seems my issue is a bit more complex than I originally thought. After doing some looking the reason I was ...
1
vote
2answers
92 views

Insert into Table ignoring duplicate values

I am having a brain fart on figuring this out. I have the following two Tables: Table: parts part_id INT IDENTITY(1,1) NOT NULL, part_number VARCHAR(50) UNIQUE NOT NULL, ...
1
vote
1answer
51 views

Innodb updates records with delay

I have two tables in my database like these: CREATE TABLE `main` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` int(11) NOT NULL, `status` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB ...
0
votes
1answer
24 views

unable to add data to table because related record is required

I have an access database with my work that I am trying to insert into but I keep getting. 'You cannot add or change a record because a related record is required in table 'Projects'.' I'm running ...
1
vote
1answer
27 views

What data is duplicated when MySQL/MariaDB BLOB columns are copied?

Let table_1 be created as follows: CREATE TABLE table_1 ( id INT AUTO_INCREMENT PRIMARY KEY, some_blob BLOB ); Let table_2 be created as follows: CREATE TABLE table_2 ( id INT ...
0
votes
1answer
302 views

Insert into DB2 table a result from temp table

Is there a way to insert a temp table results to DB2 table, for example: WITH TEMP1 AS ( SELECT CUSTOMER_ID FROM T_CUSTOMER WHERE CUSTOMER_ID BETWEEN 100 TO 300 ), TEMP2 AS ( SELECT CUTOMER_ID, ...
1
vote
1answer
49 views

How to create `instead of` trigger on a table in postgres?

I want to create a trigger for a table in postgresql. My table contains data about events and includes room number, start time and event duration. Upon new insertion to the table I want to check if ...
1
vote
3answers
410 views

How to ensure data isn't inserted into a table where the data already exists?

I've created a query which I want to insert the results into another table. It is going to be ran as a job every day, and data imported will still be kept in the result set. I don't want the data to ...
2
votes
2answers
28 views

Function Isn't Excluding Repeat Data

I am trying to insert a large amount of data into a table. The source for the data has the potential to repeat data in what is suppose to be a UNIQUE column. I created the following to insert the ...
1
vote
0answers
25 views

Long INSERT on large table blocks INSERT on other tables

Server is MySQL 5.7 and the tables are InnoDB. The large table consists of 20+ GB of data. The large table has several indexes on it and also full_text_indexes! Use-Case explained: There are ...
2
votes
3answers
433 views

Insert Into Multiple Tables At Once

I am migrating data between two databases. From the first database I am exporting a csv file that has the following columns: Customer_Name Contact_First_Name Contact_Last_Name Phone1 Phone2 Fax I ...
0
votes
1answer
25 views

Can I somehow group insert returnings?

I am trying to insert user and multiple of his user role + return id of created user in single row. I used following query: WITH inserted_user as ( insert into "user" (username, password, nickname, ...
0
votes
1answer
72 views

Insert Into Existing Table Using OpenQuery

I am attempting to insert data into a linked server using openquery. I have attempted the below syntax, but get an error of Cannot get the column information from OLE DB provider "MSDASQL" for ...
0
votes
0answers
20 views

Finding rows affected by deadlock on page locks [duplicate]

We've got a db that has been pretty much deadlock free for over 6 months, but a day or two ago we had over 60, all on the same two or three pages of the same table (~12,000,000 rows, ~250 bytes per ...
0
votes
1answer
108 views

Inserting 3 lakh (300'000) records into a table [closed]

I have a table named transaction into which I want to insert 3 lakh (300'000) records. I need it to be created as dynamic query instead of writing thousands of insert statements. For example : ...
0
votes
2answers
44 views

Combining a query for value and an insert MySQL

I have 2 tables, ranks and accounts. When inserting into accounts I fetch the ID of the rank first, storing it in a variable on the script running the queries, then insert the new account into the ...
-1
votes
2answers
364 views

How to avoid primary key violation while doing inserts

I have a code which does insert into destination table from source, but at times we are ending up with deadlocks. Due to deadlock , I have to rerun this code again. while i do re-run , I end up with ...
0
votes
1answer
45 views

How to generate and insert primary key when using SELECT DISTINCT in OracleDB?

How do I insert (or generate and insert) a primary key when I use the SELECT DISTINCT query? If I have a table made like this: CREATE TABLE testUser( username VARCHAR2(50 CHAR), email ...
3
votes
1answer
493 views

inserting a special character into a table

I have a few characters that are being replaced by a ?. How do you keep the original character in the table? The character that I am trying to insert is a ɬ; Latin Small Letter L With Belt. Is it ...
0
votes
1answer
18 views

Using WITH clause with INSERT statement in POSTGRESQL

I have a requirement in which I need to get one column from another table and insert that column data with some other data into another table. Example: If the cust_id='11' then I need to get the ...
1
vote
2answers
94 views

Postgres 10.3 : table grows in size after delete-insert

I'm a rather new to Postgres and the issue I see seems a bit strange. Maybe you as experts know something about it. I have a table (around 3 million rows and 200 columns). In order to populate fresh ...
1
vote
1answer
34 views

Block insertions on a mysql table with specific value

I've got a simple question: I was wondering if it is possible to (temporary or permanent if possible) block the insertion of a record into a table with a specific value for a specific column. I'm ...
0
votes
1answer
35 views

How to set a parent from one-to-many relationship?

I have tables as CREATE TABLE articles ( id varchar(10), parent_id varchar(10), Text text, FOREIGN KEY(parent_id) REFERENCES articles(id) ON DELETE CASCADE, PRIMARY KEY(id) ) ENGINE=InnoDB CREATE ...
1
vote
0answers
43 views

Database Behavior while executing UPDATE and INSERTs on the same table

My gear: Pentaho BI Server 8.0 AS400 V7 My scenario: I have two processes that sometimes run at same time in the same table. This table has about 600M rows, so, an update can take long time to ...