In the database structured query language (SQL), the DELETE statement removes one or more records from a table.

learn more… | top users | synonyms

0
votes
3answers
74 views

Slow DELETE in MySQL with a subquery

I am running the following DELETE SQL on a MySQL database on a MyISAM/utf8 table. The SQL is called in a loop, once time per Users (in this case):- DELETE FROM regulatory WHERE documentid IN ( ...
0
votes
1answer
23 views

ON DELETE CASCADE pseudo delete

For data integrity ON DELETE CASCADE is necessary but it's really dangerous when a delete affects like a Chain Reaction! I know one way to prevent this is to make a pseudo delete by putting a ...
2
votes
1answer
34 views

Could 'Maximum Server Memory' be too low for large batched delete with captured output?

I'm trying to improve the performance of a SQL server database backup program that will create a new database to hold one years worth of report records, delete report records out of the main database, ...
1
vote
2answers
331 views

deleting large volumes of rows from table efficiently in SQL Server [duplicate]

I have a table that has gotten a little out of control. I am not a DBA per se but seem to recall that deleting a huge volume of rows in one shot can cause transaction log issues, hamper overall system ...
1
vote
0answers
71 views

Why is this query stuck if there are no waits?

I am working with a vendor's activity logging system. One of the tables has 70+ million records and is constantly increasing at several hundred records per minute. They have a utility to delete old ...
1
vote
2answers
91 views

How to delete rows from a table when we're joining and return data?

I have two queries: The first one is as below: SELECT * FROM batch bp INNER JOIN sender_log sl ON sl.id=bp.log_id AND bp.protocol='someprotocol' The second query is used to delete rows: ...
0
votes
1answer
35 views

Is it possible (or good practice) to register data upon Deletion of a record? What would be a better solution?

The problem is the following. A company has one or more representatives (a person who speaks on behalf of the company). When a representative is deleted, it's desired to keep it in an list called ...
1
vote
1answer
117 views

MySQL master master replication, safe to delete rows on both masters?

We have a MySQL (v5.1.61) cluster with two masters (and two slaves). We have a table logs with a primary key column logID. This log table grows rather huge, and we'd like to delete data from it. So ...
0
votes
1answer
113 views

Delete Query takes a long time

I have a innodb table that counts circa 1 billion entries. I started a delete operation (with a small where condition on an indexed column) that should delete a lot entries, leaving circa 100 million. ...
2
votes
2answers
209 views

How do I Delete A Database And Log Files With SQL 2008 Script?

While working on making an automated Delete and Restore script for my backups I ran into a snag. I can not delete the database; however, the delete button works exactly how I need it to. Can anyone ...
0
votes
1answer
42 views

Effective duplication of DELETE … LIMIT in Pg

I have an unusual problem: I need to delete a certain number records from a table, of a particular type; in certain non-compliant DBs it would be easy to accomplish this with DELETE FROM sometable ...
0
votes
1answer
146 views

Delete millions of rows, fast

I currently have a database with the following structure: id->varchar(9) time->datetime val01 - val20->int(11) val21 - val40->tinyint(1) id and time are the primary key. also I defined an index ...
4
votes
1answer
346 views

Deleting Rows is Increasing Index Size

We have a very large table in a SQL Server 2008 R2 Standard server which I am archiving rows by copying them into another database on a separate disk and then deleting them from the original table ...
2
votes
3answers
167 views

MySQL: Keep the 10 most recent rows for each user

I have a table saving scores for a game that have 3 columns (more in practice, but it is easier for everyone this way): userid : the id of the user that got the score timestamp: the time the score ...
2
votes
1answer
48 views

Single statement or batched delete?

I need to delete 6.3 million records from 25 tables in production. I have the following two queries, but I don't know which one will be best: delete jc from Jtable jc join J1Table j on j.JobId = ...
0
votes
1answer
51 views

Multiple source CASCADE DELETE behavior

I'm having trouble understanding Postgres's CASCADE DELETE behavior. If table_A REFERENCES table_B, and the column referenced could have multiple instances of the same value, will the table_A row be ...
0
votes
1answer
84 views

I have delete database from mysql but storage is not freed

I have deleted multiple databases (schema) from mysql on amazon RDS but the storage is not freed, is there anything else I should do to free up the storage? I have a mysql database that the total ...
1
vote
1answer
140 views

Is it possible to raiserror within a For Delete Trigger that rolls back the deletes

There is a claim at the end of this accepted answer that if an error occurs within a "For Delete" trigger, the delete action would be rolled back because it is part of an implicit transaction. ...
2
votes
0answers
72 views

Postgres 9.3 - deletes terribly slow for 10 minutes after dropping indexes/constraints

If I run a script which drops indexes (17 of them, CONCURRENTLY makes no difference except that without it I get the occasional deadlock), then constraints (20 constraints on 18 tables) and then run a ...
5
votes
1answer
428 views

Use of FROM keyword on DELETE statement

The BOL and many other sources point out: FROM Is an optional keyword that can be used between the DELETE keyword and the target table_or_view_name, or rowset_function_limited. I'm used to ...
3
votes
1answer
688 views

Why is SQL Server using a clustered index scan for a self referencing FK cascade delete

I have made an example to allow me to show what my issue is: Setup: CREATE TABLE [dbo].[Test]( [TestId] [bigint] IDENTITY(1,1) NOT NULL, [ParentTestId] [bigint] NULL, CONSTRAINT [PK_Test] ...
1
vote
3answers
74 views

SQL Delete rows where a dataname will equal mulitple variables

Researching similar common queries have really helped but I am still none the wiser as to my issue. To note that the database I intend to use this on contains around 1000 rows (same 2 columns listed ...
0
votes
2answers
696 views

Delete an oracle instance, the right way

I want to delete an oracle instance (oracle 10.2.0.4.0) created in the AIX 6.0 OS. I know i can delete all the dbf and ctl files in the Terminal but i thinks that's no the best way to do it. I think ...
0
votes
2answers
357 views

Massive MySQL delete from CSV file

To insert massive CSV file into MySQL, there is LOAD DATA INFILE, but is there any similar command to delete massive entries with keys stored in a massive CSV file? If not, what would you see as the ...
0
votes
1answer
335 views

Deleting Record from Linked Table Slow in MS Access

I have a Microsoft Access database that is linked to a SQL Server 2000 backend. It has one form with several subforms, all using information from linked tables. When I try to delete a record from one ...
0
votes
2answers
325 views

Trigger to delete inserted record if it doesn't exist in another table

I have a question. I have two tables: zip_code (zip_id, zip_code, state) - this is a static table that stores areas I service tech_zips (tz_id, tech_id, zip) - this is where I store what zip codes ...
3
votes
2answers
212 views

Is it good practice to check for existence of records before deleting them

I've came across the following SQL/PLSQL while investigating a stored procedure written by someone else: 1. V_COUNT NUMBER(5,0); ......... 2. SELECT COUNT(*) INTO V_COUNT FROM TABLE1 WHERE ...
2
votes
1answer
138 views

Deleting 200M+ rows from InnoDB table

Basically, we have a table with the following structure: CREATE TABLE `reqs` ( `id` INT(10) NOT NULL AUTO_INCREMENT, `reqid` BIGINT(20) NOT NULL, `from` BIGINT(20) NOT NULL, `to` ...
0
votes
2answers
894 views

Delete rows in parent table based on criteria in child table - Oracle

I have a table B with a foreign key to table A. I want to DELETE some rows in table B, and I also want to DELETE their parent rows in table A. However, the delete criteria is based on table B. The ...
2
votes
3answers
548 views

Is there any time where we should avoid cascading delete?

In SQL Server 2008, there is a Primary table which is linked to three other child tables by 1 to many relationship. So, we are thinking of using Cascading delete in the primary table, so that all the ...
0
votes
1answer
396 views

How to avoid locks by large transactions?

We have a large application running, that requires cleanup for performance reasons. This was however not forseen when designing the application. Basically, the delete is executed from a stored ...
0
votes
1answer
135 views

DELETE query against a linked server issues error

I have a query that is part of a bigger process, and runs against a linked server. The code is like this: DELETE FROM [LinkServerIP].[Database].[dbo].[TableName] WHERE NOT EXISTS ( SELECT * ...
1
vote
1answer
380 views

MySQL: update instead of delete if foreign key constraint?

I have a bit of a strange question. I know about insert on duplicate key update. My question is, is there something similar for deletes that fail because of foreign key constraints? For example: ...
1
vote
2answers
1k views

Freeing space after deleting rows [duplicate]

I have a SQL Server 2008 instance and one table is quite large (log data) so I delete old logs. Now I start to read articles on this problem, here is one. As I see it there is no solution! If I ...
5
votes
2answers
364 views

What to do after deleting a million records

We are implementing a new feature in our system that will cause about a million records (each record is tiny, basically a GUID, a date, and four smallint fields) to be purged from a table every night. ...
0
votes
1answer
266 views

Mysql foreign key cascade delete

Does mysql have a way to delete all sub links if a row was deleted from a "parent" table? Example table setup is below, the issue I am trying to avoid is having to maintain a script that deletes the ...
0
votes
0answers
106 views

Importing large .sql file stops before even midway and starts deleting

Okay so i'm trying to import my minecraft servers .sql file into database and after first 1GB of importing data it stops without error and starts deleting what already has been imported any ideas? ...
1
vote
1answer
578 views

mysqldump: replace drop table in output with delete?

I am using mysqldump to dump some records in a table: mysqldump mydatabase mytable --where="field=value" this emits script that includes drop table mytable statement. Since I use the --where ...
0
votes
3answers
289 views

MySQL Large DELETE with JOINs

I have a large table players with ~20MM rows which joins to a table stats with ~300MM rows, among others (photos, ...). I want to DELETE all records for players that were born_on before 1950. I ...
1
vote
1answer
204 views

Large table delete in mysql

I want to delete a table with 10,000,000 records. Due to some restrictions I can't do truncate on that table (I don't have the DROP privilege), I can think of two options: DELETE QUICK To set some ...
2
votes
1answer
1k views

MySQL Query: Delete from 'table2' where column = 'value' IF column in 'table1' = 'value'

I am trying to execute a MySQL query to delete rows from 'table2' where column = 'value' IF column in 'table1' = 'value' I have 2 tables... Table 1 is called accounts Table 2 is called ...
-3
votes
1answer
101 views

What will the sql statement “DELETE FROM sales” do?

DELETE FROM sales; And if there are no other uncommitted transactions on the sales table. Which statement is true about the DELETE statement? It removes all the rows in the table and deleted rows ...
4
votes
5answers
863 views

Fast way of delete MySQL record

I have a 1.2 million record in a database table( it use index column also) I want to delete old 1 million record. I try to do it using PhpMyadmin but it take more time. DELETE FROM `table` WHERE ...
-1
votes
1answer
3k views

Delete from table where multiple fields match select subquery from other table

I want to delete an entry in a table where multiple fields match the results of another select subquery which takes data from another table. This is what I have so far, though it doesn't work: ...
1
vote
2answers
319 views

Approaches for deleting unnecessary records from tables

We have a database which stores the temperatures of 20 thermometer every 7 seconds. We want to delete all records in the way that every minute holds just one tempereature instead of 8 which are older ...
0
votes
1answer
124 views

Need ideas about OPTIMIZE TABLE

Looking at a database with 10 tables and fairly active at by-the-hour changes. On the first of each month, I purge some rows from 3 tables to remove outdated material and keep the size down. All of ...
1
vote
1answer
251 views

Delete entry from related tables

I can not use InnoDB engine because of some dependency troubles in LuaSQL and PtokaX. My current query is something like: DELETE e.*, m.* FROM entries e INNER JOIN magnets m ON m.eid = ...
2
votes
4answers
374 views

Delete the N oldest entries grouped by multiple columns

I´d like to delete the oldest entries of my database, but in each category shall remain at least N words of each char. Structure of TABLE words id | word | char | category For example I have the ...
1
vote
1answer
237 views

Will deleting data in master automatically delete data in slave?

I have data replication setup on MySQL. If I delete data on the master, will replication know data was deleted and automatically delete the same data on slave?
0
votes
2answers
914 views

Fastest way to delete matching rows in MySQL?

I have more than 10 million records in a table. I want to delete the records where the email column contains .ac.. What is the fastest method to perform the task? Table Schema CREATE TABLE `master` ...