...
The goal of this primer is to provide a starting point for the most common actions for working with PostgreSQL, with pointers to more in-depth documentation where applicable.
Stoc |
---|
As of Servoy 5.2 Servoy comes bundled with PostgreSQL. While While Servoy comes bundled with PostgreSQL, Servoy is 100% database agnostic. The PostgreSQL database can therefor be replaced by any type of database.
...
Through the pg_ctl tool that comes with PostgreSQL, it is easy to start and stop a PostgreSQL database. In a default installation the pg_ctl tool is located in
Code Block |
---|
../application_server/postgres_db/bin/
|
When you have used the EnterpriseDB (EDB) installer then all of PostgreSQL (binary and database cluster) is installed in the following directory:
OSX
Code Block |
---|
/Library/PostgreSQL/9.0/
|
Windows
Code Block |
---|
C:\Program Files\PostgreSQL\9.0\
|
Linux
Code Block |
---|
/opt/PostgreSQL/9.0/
|
Where the subdirectory bin holds the command-line tools and other binaries and the subdirectory data holds the database cluster. Also PostgreSQL will be running under the system user postgres and the data directory is only accesible by that user. All this is for security.
...
Using the bundled PostgreSQL (assuming you run this from within the application_server directory):
Code Block |
---|
postgres_db\bin\pg_ctl start -D database -l postgres_db\postgres_log.txt
|
When using the EDB installed version of PostgreSQL then the command is the following:
Code Block |
---|
sudo -u postgres /Library/PostgreSQL/9.0/bin/pg_ctl start -D /Library/PostgreSQL/9.0/data
|
...
Using the bundled PostgreSQL (assuming you run this from within the application_server directory):
Code Block |
---|
postgres_db\bin\pg_ctl stop -D database
|
When using the EDB installed version of PostgreSQL then the command is the following:
Code Block |
---|
sudo -u postgres /Library/PostgreSQL/9.0/bin/pg_ctl stop -D /Library/PostgreSQL/9.0/data
|
...
Registering the Windows Service:
Code Block |
---|
postgres_db\bin\pg_ctl register -N PostgreSQL -D database
|
Unregistering the Windows Service:
Code Block |
---|
postgres_db\bin\pg_ctl unregister -N PostgreSQL
|
...
Backup a specific database
Code Block |
---|
postgres_db\bin\pg_dump -U dba -Fc servoy_repository > servoy_repository.dump
|
...
Quoting for column Aliasses:
Code Block |
---|
SELECT some_column as "A nice name" FROM table
|
Quoting literal strings:
Code Block |
---|
SELECT * FROM table where text_column = 'someValue'
|
...