SELECT * FROM pg_stat_activity;
host all 172.16.0.146 255.255.255.255 trust|
Regardless of the installation type, the first step is to install the
latest cygipc from: http://www.neuro.gatech.edu/users/cwilson/cygutils/cygipc/index.html
The following is the NT services Cygwin PostgreSQL installation procedure
(with footnotes designated by "[n]"):
0. (jbp) add to the system path "C:\cygwin\bin (to allow access to the cygwindll) and then _reboot_ (argh)
1. Install the cygipc ipc-daemon as a NT service:
# ipc-daemon --install-as-service
2. Create the "postgres" user account:
# net user postgres /add /fullname:postgres /comment:'PostgreSQL user account' /homedir:"$(cygpath -w /home/postgres)"
# mkpasswd -l -u postgres >>/etc/passwd
3. Grant the "postgres" user the "Log on as a service" user right:
# cmd /c secpol.msc # [3] [4] [5]
4. Install postmaster as a NT service:
!! You will be prompted to create a postgres user password at this point
# cygrunsrv --install postmaster --path /usr/bin/postmaster --args "-D /usr/share/postgresql/data -i" --dep ipc-daemon --termsig INT --user postgres --shutdown # [6]
5. Create the PostgreSQL data directory:
# mkdir /usr/share/postgresql/data
6. Change ownership of the PostgreSQL data directory:
# chown postgres /usr/share/postgresql/data # [10]
7. Start the cygipc ipc-daemon:
# net start ipc-daemon # [7]
8. Initialize PostgreSQL (*when running under the "postgres" account*):
$ initdb -D /usr/share/postgresql/data
9. Start postmaster:
# net start postmaster # [7]
10. Connect to PostgreSQL:
# psql -U postgres template1 # [8] [9]
The following are the notes to the above:
[1] The "#" prompt indicates running as a user which is a member of the
Local Administrators group.
[2] The "$" prompt indicates running as the "postgres" user. Log in as
"postgres" or use ssh to emulate Unix's "su" command.
[3] Sorry, but I don't know of a generally available command line way of
setting user rights.
[4] On Windows 2000, this starts the "Local Security Settings" applet.
On Windows NT 4.0, do the analogous operation.
[5] See http://support.microsoft.com/default.aspx?scid=KB;en-us;q259733 for
a Microsoft KB article explaining how to configure user rights.
[6] Clean postmaster shutdown will only work with a post Cygwin 1.3.2
snapshot from 2001-Jul-28 or later.
[7] Cygwin's bin directory (e.g., C:\Cygwin\bin) must be added to the
Windows NT/2000's system PATH and the machine rebooted for the SCM
to find cygwin1.dll.
[8] Actually, psql can run under any user account.
[9] One can use PostgreSQL's createuser command or set PGUSER to obviate
the need to specify "-U postgres" on the psql command line.
[10] Assumes that ntsec is set via the CYGWIN environment variable.
|
|
Here's an explanation of each field:
| Field | Purpose |
|---|---|
| driver | The JDBC driver name.
Here, this can be either postgres95 or postgresql. postgres95 indicates that you want to connect without authentication. postgresql indicates that you want to connect using password authentication. |
| host | The host running the server. If this is absent, then it assumes localhost |
| port | The port that the server is listening to. If absent, it defaults to 5432 |
| database | The database name |
| option=value | Options about the database backend. These can be left out |
| userid | The userid. If this is leftout, then you need to pass it through the DriverManager.getConnection(url,userid,password) call. |
| password | The password. |
Heres some examples:
| jdbc:postgres95:pgtest?user=postgres&password=pass | Database pgtest on the local machine, using the userid postgres
Because we are using no-authentication, the password pass is ignored. |
| jdbc:postgresql:pgtest?user=postgres&password=pass | As above, but use password authentication. |
| jdbc:postgresql://myhost/pgtest?user=postgres&password=pass | Connect to database pgtest on server myhost, using password authentication with user postgres, password pass. |
| jdbc:postgres95://localhost:8000/pgtest?user=postgres&password=pass | Connect to the server listening on port 8000 |
| Name | Desc |
|---|---|
| Create |
CREATE [ UNIQUE ] INDEX index_name ON table
[ USING acc_method ] ( column [ ops_name ] [, ...] )
[ WHERE predicate ]
CREATE [ UNIQUE ] INDEX index_name ON table
[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] )
[ WHERE predicate ]
Example:
CREATE INDEX myIndex ON table1 (colname) ;
|
| Action | PosgreSQL |
|---|---|
| Help list of commands | \? or \h |
| Connect to another Database | \c[onnect] [DBNAME|- [USER]] |
| Listing Tables | \dt |
| Listing Databases | \l |
| Listing Databases and Views | \d |
| Show Users | \du |