看板 Database 關於我們 聯絡資訊
我用的是oracle 最近遇到一個問題 想請教有沒有比較有效的解決方法 有n個table需要常常建立 (table_1、table_2、...、table_n) 但是執行時的條件每次都不一樣 簡化如下: create table table_1 as select * from A where x in (4562,7864,1432) and y in (51321,123153) and z=35413; create table table_2 as select * from A where x in (5641,1324) and y in (86746,15345,23415) and z=54231; 其中 x,y,z 每次要帶入的數值無論是個數或是內容都沒有規律 也就是說 下次x可能只有一個值、或是有四個值不等 我想請問除了每次逐筆更改where處之外 有沒有比較有效率的方式可以處理 想了好久想不出來 煩請有經驗的高手幫幫忙 非常感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.162.216.164
moyasi:重點在x,y,z的值能不能直接select 出來 11/02 01:06
可以 只是我嘗試用 select * from A where x in (select xx from X) and y in (select yy from Y) and z=(select zz from Z) 卻非常耗時 直接給數值時間上快很多
moyasi:為什麼要一直建立table 不能寫成view嗎? 11/02 01:07
因為會需要保留這些table 作為資料的備份 假設不考慮備份的情況下 用view會比較好嗎? 我對view粗略的了解是它其實跟建立table 在code上沒有很大的不同 這樣講不知道對不對呢 最後 謝謝您的回覆 ^^ ※ 編輯: zacaria 來自: 1.162.200.47 (11/04 22:26)