Tagged Questions
17
votes
6answers
7k views
How to improve INSERT INTO … SELECT locking behavior
In our production database, we ran the following pseudo-code SQL batch query running every hour:
INSERT INTO TemporaryTable
(SELECT FROM HighlyContentiousTableInInnoDb WHERE ...
11
votes
3answers
24k views
Add row to query result using select
Hey guys, is it possible to extend query results with literals like this?
Select name from users
union
select name from ('JASON');
or
Select age, name from users
union
select age, name ...
9
votes
2answers
388 views
Mysql: SELECT * FROM … without one field
For duplicating an entry I would like to use the following syntax:
insert into TABLE select * from TABLE where ...
However, as the first column is an auto-increment primary key, this value must be ...
8
votes
3answers
6k views
MySql insert the results of a select
I would like to know if I can run a request like that:
INSERT INTO t2 (a, b)
VALUES (
SELECT a, b
FROM `t1` AS o
WHERE o.id NOT
IN (
SELECT a
FROM t2
)
)
The idea is to fill the t2 ...
7
votes
1answer
10k views
How to insert date in sqlite through java
I want to make a database that will hold a date in it(SQLite).
Now first to ask is what is the right syntax to declare a date column.
The second i want to know is how to insert date in it after that.
...
6
votes
9answers
4k views
SQL SELECT INSERT INTO Generate Unique Id
I'm attempting to select a table of data and insert this data into another file with similar column names (it's essentially duplicate data). Current syntax as follows:
INSERT INTO TABLE1 (id, id2, ...
6
votes
6answers
101k views
Oracle Insert via Select from multiple tables where one table may not have a row
I have a number of code value tables that contain a code and a description with a Long id.
I now want to create an entry for an Account Type that references a number of codes, so I have something ...
6
votes
3answers
6k views
Hibernate, insert or update without select
I have a products objects which belongs to certain categories i.e. classical many to one relationship.
@Entity
public class Product{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
...
6
votes
1answer
6k views
Insert multiple rows using select
I am trying to insert 2 rows into the same table. The first will input data from a select, the second will use vars for data. I am able to insert the first row but having trouble inserting multiple ...
6
votes
3answers
674 views
MyISAM Selects locks inserts inside procedure only
We have a large MyISAM table to which rows get inserted to the bottom of the table only.
While doing some benchmarks, i realized that selects do not (always) lock other inserts to that same table. ...
5
votes
3answers
906 views
T-SQL Delete Inserted Records
I know the title may seem strange but this is what I want to do:
I have table with many records.
I want to get some of this records and insert them in other table. Something like this:
INSERT INTO ...
5
votes
1answer
13k views
Insert data into table with result from another select query
I am seeking help on the following issue:
I have two tables
Table_1 columns are itemid, locationid, quantity
Table_2 columns are itemid, location1, location2, location3
I want to copy data from ...
5
votes
1answer
779 views
#1411 - Incorrect datetime value for function str_to_date on INSERT INTO…SELECT
These queries require the string to date conversion because Timestamp is stored as a string, and the logging application is unchangeable.
I have a select query that works perfectly ->
(SELECT ...
4
votes
2answers
3k views
MySQL INSERT with multiple nested SELECTs
Is a query like this possible? MySQL gives me an Syntax error. Multiple insert-values with nested selects...
INSERT INTO pv_indices_fields (index_id, veld_id)
VALUES
('1', SELECT id FROM pv_fields ...
4
votes
4answers
435 views
Select From a table that is constantly being inserted into
How would I go about grabbing data from a table that is CONSTANTLY being inserted into (and needs to be) without causing any locking so that the inserts will continue unheeded.
I've looked around and ...