Questions tagged [delete-row]

Delete row refers to the removal of rows from a relational database.

The deletion can be achieved by using the DELETE statement of the SQL language.

1917 questions
984
votes
18 answers

Deleting DataFrame row in Pandas based on column value

I have the following DataFrame: daysago line_race rating rw wrating line_date 2007-03-31 62 11 56 1.000000 56.000000 2007-03-10 83 11 67 …
TravisVOX
  • 20,342
  • 13
  • 37
  • 41
333
votes
14 answers

Reset AutoIncrement in SQL Server after Delete

I've deleted some records from a table in a SQL Server database. The IDs in the table look like this: 99 100 101 1200 1201... I want to delete the later records (IDs >1200), then I want to reset the auto increment so the next autogenerated ID will…
jumbojs
  • 4,768
  • 9
  • 38
  • 50
263
votes
7 answers

Difference between Destroy and Delete

What is the difference between @model.destroy and @model.delete For example: Model.find_by(col: "foo").destroy_all //and Model.find_by(col: "foo").delete_all Does it really matter if I use the one or the other?
Saggex
  • 3,390
  • 3
  • 22
  • 37
229
votes
6 answers

Deleting rows with MySQL LEFT JOIN

I have two tables, one for job deadlines, one for describe a job. Each job can take a status and some statuses means the jobs' deadlines must be deleted from the other table. I can easily SELECT the jobs/deadlines that meets my criteria with a LEFT…
fabrik
  • 14,094
  • 8
  • 55
  • 71
198
votes
24 answers

Removing duplicate rows from table in Oracle

I'm testing something in Oracle and populated a table with some sample data, but in the process I accidentally loaded duplicate records, so now I can't create a primary key using some of the columns. How can I delete all duplicate rows and leave…
juan
  • 80,295
  • 52
  • 162
  • 195
169
votes
12 answers

MySQL InnoDB not releasing disk space after deleting data rows from table

I have one MySQL table using the InnoDB storage engine; it contains about 2M data rows. When I deleted data rows from the table, it did not release allocated disk space. Nor did the size of the ibdata1 file reduce after running the optimize table…
Sumit Deo
  • 2,196
  • 2
  • 15
  • 12
155
votes
6 answers

How to delete a certain row from mysql table with same column values?

I have a problem with my queries in MySQL. My table has 4 columns and it looks something like this: id_users id_product quantity date 1 2 1 2013 1 2 1 2013 2 2 …
Dani
  • 1,581
  • 2
  • 10
  • 8
148
votes
13 answers

Delete all data in SQL Server database

How I can delete all records from all tables of my database? Can I do it with one SQL command or I need for one SQL command per one table?
AndreyAkinshin
  • 18,603
  • 29
  • 96
  • 155
111
votes
18 answers

Deleting Row in SQLite in Android

This might be a dumb question, but I'm new to SQLite and I can't seem to figure this out. I have 1 table that has columns KEY_ROWID, KEY_NAME, KAY_LATITUDE, and KEY_LONGITUDE. I want the user to be able to select one and delete it; Can anyone give…
user766650
107
votes
6 answers

deleting rows in numpy array

I have an array that might look like this: ANOVAInputMatrixValuesArray = [[ 0.96488889, 0.73641667, 0.67521429, 0.592875, 0.53172222], [ 0.78008333, 0.5938125, 0.481, 0.39883333, 0.]] Notice that one of the rows has a zero value at the end. I…
MedicalMath
  • 1,071
  • 2
  • 7
  • 3
103
votes
10 answers

Delete duplicate records in SQL Server?

Consider a column named EmployeeName table Employee. The goal is to delete repeated records, based on the EmployeeName field. EmployeeName ------------ Anand Anand Anil Dipak Anil Dipak Dipak Anil Using one query, I want to delete the records which…
usr021986
  • 3,421
  • 14
  • 53
  • 64
102
votes
14 answers

Deleting specific rows from DataTable

I want to delete some rows from DataTable, but it gives an error like this, Collection was modified; enumeration operation might not execute I use for deleting this code, foreach(DataRow dr in dtPerson.Rows){ …
namco
  • 6,208
  • 20
  • 59
  • 83
95
votes
5 answers

Linq to Sql: How to quickly clear a table

To delete all the rows in a table, I am currently doing the following: context.Entities.DeleteAllOnSubmit(context.Entities); context.SubmitChanges(); However, this seems to be taking ages. Is there a faster way?
Svish
  • 152,914
  • 173
  • 462
  • 620
79
votes
5 answers

Deleting records before a certain date

How would I go about deleting all records from a MySQL table from before a certain date, where the date column is in DATETIME format? An example datetime is 2011-09-21 08:21:22.
Hard worker
  • 3,916
  • 5
  • 44
  • 73
76
votes
4 answers

SQL DELETE with JOIN another table for WHERE condition

I have to delete rows from guide_category that have no relation with guide table (dead relations). Here is what I want to do, but it of course does not work. DELETE FROM guide_category AS pgc WHERE pgc.id_guide_category IN (SELECT…
hsz
  • 148,279
  • 62
  • 259
  • 315
1
2 3
99 100