問題描述
我有一個 CTE,它是一個表上的選擇語句.現在,如果我從 CTE 中刪除 1 行,它會從我的基表中刪除該行嗎?
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?
如果我有一個臨時表而不是 CTE,也是同樣的情況嗎?
Also is it the same case if I have a temp table instead of CTE?
推薦答案
檢查 DELETE 語句文檔,是,您可以使用 CTE 從中刪除,它會影響基礎表.同樣對于 UPDATE 語句...
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...
如果我有一個臨時表而不是 CTE,也是同樣的情況嗎?
Also is it the same case if I have a temp table instead of CTE?
不,從臨時表中刪除只會影響臨時表——數據來自的表沒有連接,臨時表是一個獨立的對象.
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.
這篇關于從 SQL SERVER 中的 CTE 中刪除行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!