PostgreSQL Notes

 

OS X: How to start / stop Postgre SQL Server on OS X. This may work on other flavors of linux also.

  1. Enable the root user (http://support.apple.com/kb/ht1528).
  2. Open a terminal window.
  3. Type “su” and press enter. Enter the password to login as root.
  4. Type “su – postgres” to login as postgres
  5. cd to /<install_dir>/PostgreSQL/9.0/bin
  6. type ./pg_ctl stop -D /<install_dir>/PostgreSQL/9.0/data

I’m open to suggestions for an easier way.

Insert where not exists

This method is not specific to Postgre and should work with any database.

INSERT INTO table1 (field1,field2)
SELECT 'value1','value2' WHERE NOT EXISTS
(SELECT field1,field2 FROM table1 WHERE field1 = 'value1' AND field2 = 'value2');

Source: http://farismadi.com/blog/2009/03/13/postgres-insert-if-not-exist-else-ignore/

 Posted by at 4:50 pm

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)