Questions tagged [delete]

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

In the database structured query language (SQL), the DELETE statement removes one or more records from a table. A subset may be defined for deletion using a condition, otherwise all records are removed.

Questions with the delete tag regards deletion of records, columns, tables, files and other content or structure using SQL statements or GUI-operations.

More to read: http://en.wikipedia.org/wiki/Delete_(SQL)

455 questions
18
votes
2 answers

Tombstone Table vs Deleted Flag in database syncronization & soft-delete scenarios

I need to keep track of deleted items for client synchronization needs. In general, is it better to add a tombstone table and a trigger that tracks when a row was deleted from the server database - basically adding a new row to the tombstone table…
Lorenzo Polidori
  • 291
  • 1
  • 2
  • 5
1
vote
3 answers

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 below) of which 300-350 will need deleting…
Sam Ryder
  • 23
  • 2
0
votes
0 answers

Should I use soft delete as a record-disabling mechanism or better set another field to mark records as deactivated?

I'm making a web app with Laravel and PostgreSQL where many records in almost all tables in the database need to be kept by historical reasons (users need to search old data for statistical reasons). Laravel provides soft-deleting working…
Dovahkiin
  • 1
  • 1
0
votes
1 answer

Deleting records based on an offset from creation date

Basically, I have a table where I store messages for each user. Each user is allocated 1,000 messages, by 30 days. id user_id message created_at 1 12 ... 2020-01-01 16:30:45 2 45 ... 2020-01-02 16:31:12 3 12 ... 2020-01-02…
DarkGhostHunter
  • 153
  • 1
  • 7
0
votes
1 answer

What does the alias after DELETE mean?

What does the alias after DELETE mean? E.g. I have a query: DELETE p1 FROM Person p1, Person p2 WHERE p1.Email = p2.Email AND p2.Id < p1.Id What does it mean DELETE p1? I understand it as follows. First we find a cartesian product of the Person…
some1 here
  • 105
  • 2