2005年02月19日
[Database] 為資料表與欄位加中文註解
欄位結構內並無註解(Comment, Oracle使用的名詞,MS SQL Server稱為描述:Description),但我們可以用下列指令附加上去:
(Oracle)
(MS SQL Server)
要加註解當然不用這麼麻煩,直接用Enterprise Manager之類的工具輸入即可。SQL Server顯示描述的指令實在是太難記了,我們可以寫一個函數來簡化:
以後便就可以用以下指令來查欄位描述了:
##
...繼續閱讀
(Oracle)
-- 替資料表TABLE1的欄位COL1加上中文註解
comment on column TABLE1.COL1 is '欄位註解';
-- 由User_tab_comments顯示註解
select * from user_tab_comments;
(MS SQL Server)
-- 描述是SQL Server欄位的延伸屬性
exec sp_addextendedproperty N'MS_Description', '中文描述', N'user',
N'dbo', N'table',N'表格名稱', N'column', N'欄位名稱'
-- 顯示指定表格的所有欄位描述
SELECT * FROM ::fn_listextendedproperty (NULL, 'user', 'dbo',
'table', '表格名稱', 'column', default)
要加註解當然不用這麼麻煩,直接用Enterprise Manager之類的工具輸入即可。SQL Server顯示描述的指令實在是太難記了,我們可以寫一個函數來簡化:
CREATE FUNCTION Describe (@table varchar(30))
RETURNS TABLE
AS
RETURN (
SELECT * FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table',
@table, 'column', default)
)
以後便就可以用以下指令來查欄位描述了:
select * from Describe('表格名稱')
##
...繼續閱讀
2005年02月18日
[Database] 快速顯示SQL Server Online Book的指令
自從更新了新版(2004?)的線上叢書後,就再也無法在Query Analyzer中按F1開啟線上叢書視窗,而必須隨便打個SQL命令再按Shift+F1,或者由程式集中找,有點煩人。今天特別去找出它的啟動指令:
C:\WINDOWS\hh.exe "C:\Program Files\Microsoft SQL Server\80\Tools\Books\SQL80.col"
做個批次檔再放到桌面或快速啟動列,以後需要查SQL資料時,就能迅速的找到了。
##
2005年01月31日
Aqua Data Studio 3.7.23 更新
Aqua Data Studio今天更新了3.7.23版,在標題列是用這個版本號碼,但在「關於」視窗中已改標成4.0了,看來快要跳成4.0版了。
3.7.23主要是配合jTDS推出的1.0(終於到1.0了)而更新:
FEATURE: MS SQL Server 7.0 & 2000/5 - Added Windows Authentication
- Added Option: "Windows Single Sign-On" option to allow a
user to login using Windows Authentication with the currently logged in
username/password of the Windows OS. (Only supported on Windows OS)
- Added Option: "Windows Authentication" option to login
using Windows Authentication with the specified username/password. (Only
Windows Authentication Option supported on non-Windows platforms (Linux,
OSX, etc)
- Requires latest jTDS Driver 1.0 with ntlmauth.dll
(http://www.aquafold.com/download/jdbc-drivers/jTDS/)
更新步驟:
##
3.7.23主要是配合jTDS推出的1.0(終於到1.0了)而更新:
FEATURE: MS SQL Server 7.0 & 2000/5 - Added Windows Authentication
- Added Option: "Windows Single Sign-On" option to allow a
user to login using Windows Authentication with the currently logged in
username/password of the Windows OS. (Only supported on Windows OS)
- Added Option: "Windows Authentication" option to login
using Windows Authentication with the specified username/password. (Only
Windows Authentication Option supported on non-Windows platforms (Linux,
OSX, etc)
- Requires latest jTDS Driver 1.0 with ntlmauth.dll
(http://www.aquafold.com/download/jdbc-drivers/jTDS/)
更新步驟:
- 把 datastudio_3_7_23.jar 拷貝成 c:\program files\Aqua Data Studio 3.7\lib\datastudio.jar
- 把 jtds.jar 拷貝到 c:\program files\Aqua Data Studio 3.7\lib
- 把 ntlmauth.dll 拷貝到 c:\program files\Aqua Data Studio 3.7
##
終於比較清楚Aqua Data Studio的Execute Current要如何操作了
在TOAD中的Execute Current指的是在SQL Editor的多個SQL敘述中的,將游標停到要執行的位置處後,按下Ctrl-Enter則只執行游標處的敘述。
這樣的動作在SQL Server的Query Analyzer中要先將敘述選取好再按Ctrl-E或F5執行,若未標示則SQL Editor內的所有敘述都會被執行。
比較起來當然是TOAD的方法比較方便。
在Aqua Data Studio中有一個Execute Current的按鈕,原以為如同TOAD般將游標移到位置後按該按鈕即可只執行游標處的敘述,結果事與願違,每個敘述都會被執行。後來找到能讓Execute Current正確執行的方法了:
1.功能表 File→Options→General 將「';' Statement separator」打勾
2.在SQL Editor中輸入的敘述都要以分號結尾
3.將游標停在要執行的敘述此處按Ctrl-Enter或點選Execute Current
##
這樣的動作在SQL Server的Query Analyzer中要先將敘述選取好再按Ctrl-E或F5執行,若未標示則SQL Editor內的所有敘述都會被執行。
比較起來當然是TOAD的方法比較方便。
在Aqua Data Studio中有一個Execute Current的按鈕,原以為如同TOAD般將游標移到位置後按該按鈕即可只執行游標處的敘述,結果事與願違,每個敘述都會被執行。後來找到能讓Execute Current正確執行的方法了:
1.功能表 File→Options→General 將「';' Statement separator」打勾
2.在SQL Editor中輸入的敘述都要以分號結尾
3.將游標停在要執行的敘述此處按Ctrl-Enter或點選Execute Current
##
2005年01月30日
壓縮工具比較:7-Zip, ZipGenius, TUGZip
今天找了3套Free的壓縮/解壓縮工具來評比,最後由TUGZip勝出。
- ZipGinius: 因裝成Beginner操作介面,用起來不甚順手,因此沒多久就解除安裝了。
- 7-Zip
- 優點:
- 有中文介面
- 介面簡單清楚,極易操作
- 能與右鍵功能表(Context menu)整合,且能以子功能表項目方式呈現
- 自創7z壓縮格式之壓縮比較ZIP佳
- 有命令列指令可以使用
- 能建立常用目錄建立成我的最愛
- 有中文介面
- 缺點:
- .iso等CD ROM image格式未支援
- 右鍵功能表有時會由中文變成英文,應該是程式的Bug?
- .iso等CD ROM image格式未支援
- 優點:
- TUGZip
- 優點:
- 前4項7-Zip的優點都有! (中文介面未整合在安裝程式內而要另行下載)
- 有三種顯示模式可選擇切換
- 能壓縮超過4GB的檔案
- 前4項7-Zip的優點都有! (中文介面未整合在安裝程式內而要另行下載)
- 缺點:
- 無命令列指令(但3.0後有增加一個Script工具,尚未測試是否能用成命令列指令)
- 記憶體耗用較7-Zip多
- 無命令列指令(但3.0後有增加一個Script工具,尚未測試是否能用成命令列指令)
- 優點:
