第七章

創建臨時資料表和查詢系統資料表

•臨時資料表,最後一定會被server drop,即時沒有下drop table指令

•有兩種類型

–Shareable

–Session-specific

•Shareable

•建立之後,所有人都可以使用和觀看

•drop table 的時間點

–使用者自行drop table

–server重開機的時候

•Session-specific

•只有特定的人員可以觀看

•drop table的時間點

–自行下drop table

–session 結束的時候

•產生臨時資料表的時機

•user

•查詢一個複雜的查詢條件

•一個存儲過程的中間工作

•server

•持有需要訂購或查詢,消除非重複值的中間結果

•查詢一個帶有Aggregate或Compute的查詢

selsect into

•複製資料表

•select column_list into new_table_name from old_table_name [where condition]

•因為select into 不會寫log,所要設定開啟

•sp_dboption db_name, “select into” true

System Table

•系統資料表是存儲資料表的建立和維護相關訊信息或它的資料庫

•master的system table除了記錄自已的系統資訊之外,還會記錄所有資料表的資訊

•system tables 無法由使用者去新增或更新資料

•可以查詢system tables

•select * from sysobjects where type = “v”

•u:user table

•v:view table