本文介绍了如何在高速公路上从SQL中删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨 我想从一张表中删除近4个lac数据,表中有近10个lac 但是只有4个lac数据我想要删除。 但同时用户或在网站上使用sama数据库。 我试图删除但它对用户来说已经慢了 所以我删除了前1000名的记录。 如何在一次尝试中删除这4个lac而不会让用户变慢 请告诉我有什么选择吗? 谢谢
Hi I wants to delete nearly 4 lac data from one table which has nearly 10 lac in table But only 4 lac data i wants delete. But same time Users or using the sama data base in website. I tried to delete but it made dead slow for the user So Am deleting like top 1000 record . How can i delete this 4 lac in one attempt without making slow for user Please tell me is there any option ? Thanks
推荐答案阅读以下内容: stackoverflow/questions/1522057/what-is-the-fastest-way-to -slete-massive-of-record-in-sql [ ^ ] Read the following : stackoverflow/questions/1522057/what-is-the-fastest-way-to-delete-massive-numbers-of-records-in-sql[^]
尝试批量删除行 Try to delete rows in batch declare @batchSize int declare @startValue int declare @endValue int declare @Counter int SET @batchSize = 100 SELECT = MIN (stockId) from t_core_stock SELECT @endValue = MAX (stockId) from t_core_stock SET @Counter = @startValue WHILE (@Counter <=@endValue) BEGIN DELETE t_core_stock WHERE StockID BETWEEN @Counter AND @batchSize SET @Counter = @Counter + @batchSize END
在你的表中,任何主键都在那里首先,您需要删除主键并删除记录,然后添加主键,如下所示。 Hi, In your table any Primary Key is there then first you need to Drop Primary Key and Delete the Records then Add Primary Key like as follows. ALTER TABLE <tablename> DROP CONSTRAINT <pkname> MAKE YOUR DELETE HERE ALTER TABLE <tablename> ADD CONSTRAINT <pkname> PRIMARY KEY (ColumnName>) </pkname></tablename></pkname></tablename>
问候, GVPrabu
Regards, GVPrabu
更多推荐
如何在高速公路上从SQL中删除数据
发布评论