沒有使用官方的安裝包,而是下載的zip解壓包.
解壓后,可以象下面這樣操作
首先新建一個windows用戶postgres(這個可以變的)
給予postgres用戶對目錄的操作權限
cacls . /E /T /D postgres
cacls . /E /T /G postgres:R
cacls .\data /E /T /P postgres:C
將數據庫注冊為windows服務
.\bin\pg_ctl register -N myPostgresServer -d .\data -Upostgres -Ppostgres
其中myPostgresServer是自定義的服務名,兩個postgres分別是新建的windows用戶的名稱和密碼
創建數據庫
執行.\bin\initdb.exe,將會創建缺省的template1數據庫,(這一步需要使用runas /user:postgres cmd進入命令行,否則postgres會拒絕管理員操作,因為postgres認為這樣不安全)
然后 psql -dtemplate1 -Upostgres進入postgres操作終端,
create database myDatabase
\q退出
psql -dmyDatabase -Upostgres
進入postgres并連接到新建立的數據庫 (還不知道怎么切換數據庫,:(
下面是一些常用的sql語法
\l列出所有數據庫名稱
\dp列出所有的表
select current_time;當前時間
select version();posgres版本
select user;當前登錄用戶
postgres中沒有datetime類型,如果你要那種有日期和時間的需要使用timestamp
最后我是在winXP pro +SP2上運行的postgres8.0.3
使用create database someDb with encoding='euc_cn'創建中文支持,
jdbc驅動:org.postgres.Driver
hibernateDialect::org.hibernate.dialect.PostgreSQLDialect
連接:jdbc:postgresql://localhost/someDb