sql-delete

Postgresql slow delete from where exists

我只是一个虾纸丫 提交于 2021-02-20 04:06:39
问题 I'm having trouble with slow delete queries. I have a schema ,say "target" containing tables that all have an equivalent table (identical columns & primary keys) in another one, say "delta". I now want to delete all rows that appear in the delta schema from the target schema. I have tried this using the DELETE FROM WHERE EXISTS approach, but that seems incredibly slow. Here's an example query: DELETE FROM "target".name2phoneme WHERE EXISTS( SELECT 1 FROM delta.name2phoneme d WHERE

Postgresql slow delete from where exists

断了今生、忘了曾经 提交于 2021-02-20 04:05:06
问题 I'm having trouble with slow delete queries. I have a schema ,say "target" containing tables that all have an equivalent table (identical columns & primary keys) in another one, say "delta". I now want to delete all rows that appear in the delta schema from the target schema. I have tried this using the DELETE FROM WHERE EXISTS approach, but that seems incredibly slow. Here's an example query: DELETE FROM "target".name2phoneme WHERE EXISTS( SELECT 1 FROM delta.name2phoneme d WHERE

Codeigniter Delete … Where … and

血红的双手。 提交于 2021-02-17 03:22:21
问题 I need a little help. How can i send this query with codeigniter? Delete FROM friendconnect WHERE who = 5 and whos = 1 OR whos = 5 and who = 1; I found only that: $this->db->where('id', $id); $this->db->delete('mytable'); Thanks everybody! 回答1: $this->db->where('who', 5); $this->db->where('whos', 1); $this->db->or_where('whos', 5); $this->db->where('who', 1); $this->db->delete('friendconnect'); This is also an alternative: $this->db->where('who', 5)->where('whos', 1)->or_where('whos', 5)-

Codeigniter Delete … Where … and

南笙酒味 提交于 2021-02-17 03:22:19
问题 I need a little help. How can i send this query with codeigniter? Delete FROM friendconnect WHERE who = 5 and whos = 1 OR whos = 5 and who = 1; I found only that: $this->db->where('id', $id); $this->db->delete('mytable'); Thanks everybody! 回答1: $this->db->where('who', 5); $this->db->where('whos', 1); $this->db->or_where('whos', 5); $this->db->where('who', 1); $this->db->delete('friendconnect'); This is also an alternative: $this->db->where('who', 5)->where('whos', 1)->or_where('whos', 5)-

I want to delete duplicate rows from my database table

☆樱花仙子☆ 提交于 2021-02-11 14:53:28
问题 I went through a few answers on this topic but none of them are executing on my workbench. I have duplicate rows in my table and I want to delete all retaining only one of them. First I grouped them by Count function and then tried deleting them but it isn't working. I tried running CTE query from old questions on the website: WITH ReferenceDP AS ( SELECT[ReferenceId1], row_number() OVER(PARTITION BY ReferenceId1 ORDER BY ReferenceId1) AS [rn] FROM TABLE ) DELETE ReferenceDP WHERE [rn] > 1

Oracle 12c - drop table and all associated partitions

你说的曾经没有我的故事 提交于 2021-02-10 18:50:26
问题 I created table t1 in Oracle 12c. Table has data and it is partitioned on list partition and also has subpartitions. Now I want to delete whole table and all associated partitions (and subpartitions). Is this the right command to delete all? DROP TABLE t1 PURGE; 回答1: When you run DROP then the table is removed entirely from database, i.e. the table does not exist anymore. If you just want to remove all data from that table run truncate table T1 drop storage; You can also truncate single (sub-

How to remove 'wasted rows' after delete in Oracle SQL database

☆樱花仙子☆ 提交于 2021-02-08 07:20:18
问题 In Oracle sql database, a process in our system deleted (not truncated) approx 2 million rows from a table. This resulted in a huge number of 'wasted rows' causing the queries running on that table to take more than 9 hours which usually get over in 5 minutes. Upon checking, we found that the size of total number of actual rows was of around 2600MB whereas the overall table including 'wasted rows' had a size of 3700MB. Please let me know what is the best way to delete rows and then get rid of

is there an alternative to query with DELETE snowflake SQL statement with CTE?

試著忘記壹切 提交于 2021-01-29 19:42:49
问题 On snowflake, is there an alternative to query with DELETE SQL statement with CTE? seems it is not possible. with t as ( select * from "SNOWFLAKE_SAMPLE_DATA"."TPCDS_SF100TCL"."CALL_CENTER" ), p as (select t.CC_REC_END_DATE, t.CC_CALL_CENTER_ID , t.CC_REC_START_DATE from t where 1=1 AND t.CC_REC_START_DATE > '2000-01-01') delete from p For example: if we use a select, we got some results. but if I use a delete. It shows a syntax error 回答1: The problem with this thinking is that SELECT returns

Create procedure that deletes data from several tables. SQL Server

早过忘川 提交于 2021-01-29 14:54:01
问题 I need to create a procedure that allows me to delete data from several tables at once, searching through the CUIT . There are four tables shown here: I must pass a CUIT value in, and if it matches any item saved in the database, I need it to be deleted. I could not find the syntax to be able to erase more than two tables at once, if you could give me a hand I would greatly appreciate it. I clarify by the doubts that the procedure is actually much larger, in total it would be about 12 tables,

Deleting records from one table joined onto another table SQL

谁说我不能喝 提交于 2021-01-28 11:33:10
问题 I have two tables one with 212,000 records (deprecated records) and the other with 10,500,000 records I would like to join the two tables on id and version_number fields as both tables have these fields. I was hoping that from the joined table that the matched records (from the joined tables) could be deleted i.e all of the 212,000 records get deleted from the 10,500,000 I was wondering what the best approach would be for this using Oracle SQL? I have seen example where inner join has been