Search Google

Tuesday, February 03, 2009

Oracle 10g and SQuirrel SQL

是的,今天要討論的是題目就是建立Oracle 10g database然後用免費的SQuirrel SQL連線進行檢視或修改。
安裝Oracle 10g十分容易因此不在這裡贅述,唯一要說明的是只要安裝Oracle 10g即可,不要勾選"建立起始資料庫",這樣可以節省不少空間。


安裝完之後點選
[開始] -> [所有程式] -> [Oracle - OraDb10g_home1] -> [組態設定核轉移工具] -> [資料庫組態輔助程式] (aka. DBCA)
有了這個幫手讓建立資料庫不再是難事,google上有很多介紹如何使用command line建立資料庫的連結,實際上跟著做過之後就會發現其實手續十分繁雜~
花點腦筋依序按下"下一步"之後資料庫就建立好了,這裡要注意的是請記得SID,之後的很多地方都會用到。
資料庫建立好了不代表我們現在就可以連到資料庫,接著我們需要建立並設定Network Listener(網路監聽器)。


請點選
[開始] -> [所有程式] -> [Oracle - OraDb10g_home1] -> [組態設定核轉移工具] -> [網路組態輔助程式] (aka. NETCA)
我們需要執行"網路組態輔助程式"兩次,第一次設定網路監聽器,第二次是設定區域網路服務名稱,在兩次的組態過程中請在"網路監聽器"與"服務名稱"中填入SID。


接著follow下面的link設定SQuirrel SQL。
http://www.norgesinternettforum.no/archive/index.php?t-1935.html
quote:

1. add the oracle driver
drivers > new driver
click on the Extra Class Path tab and press the button Add
browse to find the file on your hard drive called ojdbc14.jar
on my machine i had it in the weblogic installation directory, here:
/usr/bea/weblogic81/server/lib

Name: oracle 9 driver
Example URL: jdbc:oracle:thin:@10.0.0.150:1521:myoracledb
Website URL: http://oracle.com
Class Name: oracle.jdbc.driver.OracleDriver

the italicized texts are up to you what you write there. i got our information from this file on our bea server:
/usr/bea/user_projects/domains/myapp/config.xml

2. make the connection
aliases > new alias

Name: oracle 9 driver connection
Driver: (choose oracle 9 driver from the dropdown list)
User name: scott
Password: tiger
OK

highlight oracle 9 driver connection in the alias window and push the connection button or do the keyboard combination control+o
push the connect button
其中有幾個地方可以修改一下:

  1. "Oracle Thin Driver"即可,不需要新增一個新的driver名稱。
  2. 連線的時候把User Name從連結中的scott改成system,密碼就是建立資料庫時輸入的密碼。

連上資料庫之後到SQL tab使用create user與grant user的SQL指令新增資料庫的使用者,
或者如下面link的第一項。
http://life.iiietc.ncu.edu.tw/xms/forum/show.php?id=3337
quote:

1.login user: system
(1) --建立一個user名稱test01(CREATE USER test01)密碼預設為test01(語法:IDENTIFIED BY test01)
CREATE USER TEST01 IDENTIFIED BY test01 ;
(2) --賦予test01可以連接資料庫的權限
GRANT CREATE SESSION TO test01;
(3) --建立一個user test02,且賦予連線權限
CREATE USER TEST02 IDENTIFIED BY test02 ;
GRANT CREATE SESSION TO test02;

但是重點是以下這一行:
grant connect, resource to username;

[20090224]再更新一下:
ORACLE用ORACLE_SID來指定要連接到哪個DB,所以在下connect之令之前要記得先設定ORACLE_SID,在Linux的bash中用export,在Windows的"cmd"中用set。


做完這一系列的設定之後深深地發覺。。。Apache Derby在設定與使用上真是太簡單了!