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

learn more… | top users | synonyms (1)

1
vote
2answers
87 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 ...
0
votes
1answer
36 views

Trigger to delete with cascade effects [closed]

Hi I am new to Oracle triggers. Your help will be much appreciated! I have the following 2 tables: Product: CREATE TABLE Product (prodId varchar(10) NOT NULL PRIMARY KEY, prodName varchar(30) ...
0
votes
0answers
6 views

Efficient Method to retrieve Child Records in PL/SQL based on parent record Result set

I am writing a PL/SQL procedure to delete records from several tables where I have one parent table and several child tables with FK to parent record Id. First will do a select on parent table to get ...
0
votes
1answer
46 views

How to Delete rows based on a combination of columns having a certain count

I'm having trouble writing a query for the table below. CREATE TABLE `c_example` ( `id` int(11) NOT NULL AUTO_INCREMENT, `c_id` int(11) DEFAULT NULL, `guid` varchar(32) DEFAULT NULL, `...
4
votes
1answer
558 views

Partialy Solved - Problems Deleting Data

I did a workaround that solved the problem for today but I want to know what I did wrong for the next project. I'm stuck on trying to delete some information on my MySQL database. I've never used a ...
12
votes
1answer
260 views

Clustered index not used in a delete statement

I have a SQL Server table defined as follow CREATE TABLE [dbo].[Production_Detail] ( [Id] [bigint] NOT NULL DEFAULT (NEXT VALUE FOR [dbo].[Production_Detail_Seq]), [Meta_Data_ID] INT NOT NULL ...
1
vote
0answers
178 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? ...
0
votes
1answer
74 views

Delete query does not end

I have a following table with 1 million records : CREATE TABLE `activity` ( `id` int(9) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `subscription_id` int(10) unsigned NOT NULL, `...
0
votes
4answers
94 views

MySQL: Delete all rows older than 30 days, but only if count more than one

I need to cleanup my table of over 14.000.000 rows inside. I want to delete all entries, that are older than 30 days, but only if number of grouped items is larger than one. So, at least one item will ...
5
votes
2answers
10k views

Very slow DELETE in PostgreSQL, workaround?

I have a database on PostgreSQL 9.2 that has a main schema with around 70 tables and a variable number of identically structured per-client schemas of 30 tables each. The client schemas have foreign ...
2
votes
1answer
80 views

MySQL running delete trigger on truncate

I have a table that has an on delete trigger that updates another table. THe table I'm trying to truncate has 130,000 rows. I have duplicate schema and data on my dev server as well as the client's ...
3
votes
1answer
143 views

Delete duplicate records with no change in between

I have a products table where I insert around 150,000 records a day. Most of them are redundant, but I need to keep them because of the new expiration date. I get product feeds from about 5 out of 30 ...
4
votes
1answer
117 views

Slow Delete's of LOB data in SQL Server

I have a tables for logging, and a stored procedure to purge old data that has very slow DELETE performance, beyond what makes sense to me. I am looking for how to modify the tables or DELETE ...
0
votes
1answer
96 views

Why can't I update or delete certain records in SQL Server?

I am having a weird issue in SQL Server 2014. I cannot update or delete certain rows from a table. I can insert rows fine, and select them, but when I try to update or delete a row, I get a timeout ...
0
votes
1answer
40 views

How to delete rows from the mid of the table without any where condition?

I have a table testing with two columns id: auto_increment name: varchar(20) I fired a query select * from testing limit 1, 2 which gave me 2nd and 3rd record. Now, I want to delete these records ...
0
votes
1answer
43 views

Clear out remnant LDF log files of Sharepoint DB not visible on SBS 2008 Domain Server?

Typical ways for dealing with LDF files that take up a lot of space, recommend these processes to shrink/ eliminate the drive space being occupied. http://www.sharepointboris.net/2008/10/sharepoint-...
1
vote
1answer
76 views

MySQL - Deleting old data; Select with index taking time

I am a bit confused about 2 queries. First query I am running on a 50m rows table by index on a timestamp row with a limit, I would expect the query to be immediate regardless of the size of the ...
2
votes
1answer
1k views

Running parallel delete statements

Problem: I have a massive table - occupies a whopping 9.5 TBs. I need to delete around 5 mil rows from it. The best method I have come up with deletes 1 million records in 2 hours! Since I can not run ...
3
votes
1answer
103 views

DELETE rows which are not referenced in other table

I have two tables in a PostgreSQL 9.3 database: Table link_reply has a foreign key named which_group pointing to table link_group. I want to delete all rows from link_group where no related row in ...
1
vote
2answers
344 views

what is the quickest way to delete duplicate rows?

I need to delete duplicate rows from a large table. what is the best way to achieve that? currently I use this algorithm: declare @t table ([key] int ) insert into @t select 1 insert into @t ...
0
votes
1answer
30 views

Constraint Information - PostgreSQL 9.2

I was trying to delete some data from the table dm.billables: 1 - Select the id - PASS SELECT * INTO junk.clientid_10306 FROM dm.billables WHERE account_id = 10306; 2 - Delete the data from the ...
1
vote
1answer
302 views

Force index on a delete

UPDATE backup.records FORCE INDEX(IDX_records_deviceId) SET readyToBeDeleted = 1 WHERE deviceId = 226219 AND timestamp <= 1445255546 *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space ...
1
vote
1answer
159 views

Delete rows where matched value is twice as much

I'm trying to match two tables with two columns, table1 and table2. Each has id and price columns. I want the query to match each id and compare the price, then delete the row if the price in the ...
2
votes
2answers
38 views

MySQL Trigger Query Not Deleting As Expected

I have a test database as shown below. If date is updated in tbl1, I would like for a trigger to fire that removes all entries from tbl2 where tbl1.host = tbl2.host2 AND tbl1.date = NEW.date. This is ...
0
votes
1answer
125 views

Delete Works in one Stored Procedure but not another

I've built an app that uses stored procedures to insert into, update, and delete rows from tables in my database. All domain users have been given execute permissions on these procedures, all ...
15
votes
2answers
8k views

I need to run VACUUM FULL with no available disk space

I have one table that is taking up close to 90% of hd space on our server. I have decided to drop a few columns to free up space. But I need to return the space to the OS. The problem, though, is ...
0
votes
2answers
55 views

TSQL Delete All dates and stores data

This might sound like a stupid question but I can't seem to find a better way. It's a posting system where stores send us info on a daily basis (can be for multiple days). That info is placed in ...
2
votes
1answer
74 views

Cascade deletes from multiple tables

I have a fairly standard restaurant model with a restaurant table in a PostgreSQL DB. All restaurants have ratings (which consist of average, vote_count and vote_sum) but in order to avoid repeating ...
1
vote
1answer
192 views

Can having a LIMIT on DELETE degrade performance dramatically?

I have a database project in php and mysql. For, hopefully redundant, data security I added a LIMIT 1 to the delete($uniqueID) php function we use. Nobody cared because records really aren't ...
21
votes
6answers
5k views

DELETE command not completing on 30,000,000 row table

I have inherited a database and am looking to clean and speed it up. I have a table that contains 30,000,000 rows, many of which are junk data made by an error by our programmer. Before I add any new, ...
1
vote
1answer
395 views

DELETE statement execution cancellation in SSMS

I ran a delete statement with wrong WHERE condition (which deletes all records from table instead of just 10 records) but during execution I found it and CANCELLED the execution in Management Studio, ...
5
votes
1answer
152 views

Hard delete vs soft delete performance

I've got this table that is intended to have a lot of activity. Anything that's in it indicates that a user action is still pending. Once deleted, it would indicate that action is no longer pending. ...
1
vote
1answer
359 views

Soft delete to improve performance: all wrong?

A few years back I read soft delete would improve performance of deletion, because instead of actually removing the item and impact the clustered (and all other) indices, it would just change a value. ...
0
votes
1answer
37 views

MySQL conditional trigger delete

I have a few tables (6 to be exact) and I want to make a trigger that will delete a row from a table based on a value from the main table. To elaborate, Let's say I have a main table called "main" ...
1
vote
1answer
76 views

Can I use table aliases in a MySQL DELETE statement?

This does not work: DELETE FROM topics AS t , posts AS p USING t INNER JOIN p WHERE t.id=p.topic_id AND t.id = '5599'; whereas this does: DELETE FROM topics, posts USING topics INNER JOIN posts ...
0
votes
0answers
58 views

Why “0 pages are entirely empty” after mass delete + vacuum?

I have a huge table for logging the user actions (audit log) in my PostgreSQL 9.4 database. It gets about 100 new records per second. I've removed very old records recently. I assume this affected a ...
0
votes
1answer
34 views

How to pass parameters to delete statement?

While executing this PL/SQL block: CREATE OR REPLACE PROCEDURE procAuth_Title_Delete (auth_ID NUMBER, title_Nos IN NUMBER) IS BEGIN DELETE FROM ...
1
vote
1answer
153 views

How to delete duplicate rows in merge replication

Somehow two rows in a table that is party to merge replication are identical, including their rowguid. I have no idea how this happened, it is only with two rows in my entire database (which is used ...
0
votes
1answer
38 views

Delete with join and condition (3 tables) - MySQL

Need some assistance on MySQL delete using join with condition (3 tables). snote (child table) -------- snote_id bnote_id bnote (parent table of snote) ------ bnote_id note_id note (parent table of ...
1
vote
1answer
41 views

Delete query does not appear to open space on the SQL Server

Our SQL Server (version 2012) is housed on a cloud server, for which we pay whenever we need additional space. We determined that we could delete some of the data to prevent the need for continually ...
1
vote
0answers
28 views

Changing Action on Delete to Cascade

We have a rather big database (about 400'000'000 records) in roughly 100 tables. The foreign keys in these tables are defined, so that No Action is taken, when deleting data from a table. We now have ...
5
votes
2answers
113 views

Help optimising delete statement

Using SQL Server 2012 Standard - I'm running a delete on a table based on the contents of another table. It's taking rather a long time (5 hours) and doesn't seem to be optimal to me, would appreciate ...
1
vote
1answer
81 views

Delete Query Issue in MySQL and PHPMyAdmin [closed]

I am facing a strange issue with MySQl. I am using PHP and MySQL to built an app. When I am trying to delete records from the table it runs successfully but no record is deleted from the database. ...
0
votes
2answers
89 views

Delete “Previous” row, if a value in a column in both rows are the same

Hi I'm new to SQL so bear with me. I am essentially trying to code a report that would give me the greatest number of concurrent events. For example, peak usage of phone calls. I have a column that ...
0
votes
0answers
41 views

Why is one table taking up ~75% of time for DELETE

I have a table (Period) linked to about 6-7 other tables. When I DELETE a period, a CASCADE DELETE is used to delete the related records in the other tables. Two of the tables (Result, Amount) have ...
1
vote
1answer
28 views

Configure MariaDB to log row deletion ONLY

I'm investigating some rows/tables that intermittently go missing on a Magento site, and of course there's no entries in the error log. (I suspect Magento queries/rules or human error might be the ...
9
votes
1answer
9k views

Most efficient way of bulk deleting rows from postgres

I'm wondering what the most efficient way would be to delete large numbers of rows from PostgreSQL, this process would be part of a recurring task every day to bulk import data (a delta of insertions +...
1
vote
1answer
37 views

Oracle SQL script - passing a parameter

I have an Oracle SQL script like this: delete FROM activ_princ where id in (select ap.id FROM activ_princ ap inner join sect e on e.id=ap.FK_ID_SECTIUNE_e inner join chest ch on ...
5
votes
1answer
313 views

Alter ON DELETE CASCADE in 1 table

I'm really new to ON DELETE CASCADE. How can I delete child comments when the parent comment gets deleted in a table? Table Schema 'CREATE TABLE `comments` ( `id` int(11) NOT NULL AUTO_INCREMENT, ...
5
votes
3answers
2k views

How can a MySQL delete statement affect a table with over 30 millions records?

I have to delete about 28 million records from a InnoDB table in MySQL. I am wondering what happens if I am doing a select statement on the same table during the delete operation. I guess the delete ...