现在的位置: 首页 > 综合 > 正文

cygwin下postgresql的配置及使用(zz)

2013年09月15日 ⁄ 综合 ⁄ 共 2254字 ⁄ 字号 评论关闭
author: takhisis@smth
http://computer.mblogger.cn/abyss/

一定要让自己忙起来什么也不想, 什么也不要想, 不要想...不准想.

About PostgreSQL

PostgreSQL is an object-relational database management system (ORDBMS) based on POSTGRES, Version 4.2, developed at the University of California at Berkeley Computer Science Department. POSTGRES pioneered many concepts that only became available in some commercial database systems much later.

PostgreSQL is an open-source descendant of this original Berkeley code. It supports SQL92 and SQL99 and offers many modern features.

PostgreSQL主页

http://www.postgresql.org/

下面的叙述所针对的cygwin及postgresql版本:

$ cygcheck -cd cygwin postgresql
Cygwin Package Information
Package              Version
cygwin               1.5.10-3
postgresql           7.4.3-1

从postgresql 7.4.2-1开始, cygwin使用cygserver来支持它而不是从前的cygipc.

cygserver的配置

生成/etc/cygserver.conf
/usr/bin/cygserver-config
设置环境变量

Please keep in mind, that a client application which wants to use the services provided by cygserver *must* have the environment variable CYGWIN set so that it contains the word "server". So, if you don't need any other special CYGWIN setting, just set it to "server".

It is advisable to add this setting to the Windows system environment.

export CYGWIN=server
启动cygserver
/usr/sbin/cygserver &

postgresql的配置

postgresql的初始化
initdb -D $data_dir
启动postgresql

注意使用-i打开tcp端口

postmaster -i -D $data_dir &
启动psql
psql template1
新建数据库及表
$ createdb --encoding=EUC_CN cn_test
CREATE DATABASE

$ psql cn_test
Welcome to psql 7.4.3, the PostgreSQL interactive terminal.

Type:  /copyright for distribution terms
       /h for help with SQL commands
       /? for help on internal slash commands
       /g or terminate with semicolon to execute query
       /q to quit

cn_test=# /l
       List of databases
   Name    | Owner  | Encoding
-----------+--------+-----------
 cn_test   | $user | EUC_CN
 template0 | $user | SQL_ASCII
 template1 | $user | SQL_ASCII
(3 rows)

cn_test=# create table students (
cn_test(# id int,
cn_test(# name char(30)
cn_test(# );
CREATE TABLE
cn_test=# /dt
         List of relations
 Schema |   Name   | Type  | Owner
--------+----------+-------+--------
 public | students | table | $user
(1 row)

cn_test=# /d students
      Table "public.students"
 Column |     Type      | Modifiers
--------+---------------+-----------
 id     | integer       |
 name   | character(30) |

cn_test=# insert into students values (
cn_test(# 1,
cn_test(# '呵呵'
cn_test(# );
INSERT 25337 1
cn_test=# select * from students ;
 id |               name
----+----------------------------------
  1 | 呵呵
(1 row)

cn_test=# /q

Databases (DBs) and SQL with PostgreSQL

这个地方对sql初学者很适合的样子
http://www.felixgers.de/teaching/sql/index.html

不过其实postgresql自带的文档也蛮详细的了...至少在基本的使用方面.

抱歉!评论已关闭.