問(wèn)題描述
我有一個(gè) CTE,它是一個(gè)表上的選擇語(yǔ)句.現(xiàn)在,如果我從 CTE 中刪除 1 行,它會(huì)從我的基表中刪除該行嗎?
I have a CTE which is a select statement on a table. Now if I delete 1 row from the CTE, will it delete that row from my base table?
如果我有一個(gè)臨時(shí)表而不是 CTE,也是同樣的情況嗎?
Also is it the same case if I have a temp table instead of CTE?
推薦答案
檢查 DELETE 語(yǔ)句文檔,是,您可以使用 CTE 從中刪除,它會(huì)影響基礎(chǔ)表.同樣對(duì)于 UPDATE 語(yǔ)句...
Checking the DELETE statement documentation, yes, you can use a CTE to delete from and it will affect the underlying table. Similarly for UPDATE statements...
如果我有一個(gè)臨時(shí)表而不是 CTE,也是同樣的情況嗎?
Also is it the same case if I have a temp table instead of CTE?
不,從臨時(shí)表中刪除只會(huì)影響臨時(shí)表——數(shù)據(jù)來(lái)自的表沒(méi)有連接,臨時(shí)表是一個(gè)獨(dú)立的對(duì)象.
No, deletion from a temp table will affect the temp table only -- there's no connection to the table(s) the data came from, a temp table is a stand alone object.
這篇關(guān)于從 SQL SERVER 中的 CTE 中刪除行的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!