Postgresql service managing

## CREATE DB
$ sudo su postgres -c "initdb -D /home/postgres/data"

## REMOTE ACCESS
#in postgresql.conf
#change
listen_addresses = 'localhost' # what IP address(es) to listen on;
#to
listen_addresses = '*' # what IP address(es) to listen on;

#in pg_hba.conf
# change like
host all all 0.0.0.0/0 trust
#host all all 127.0.0.1/32 trust

## START DB
$ /usr/lib/postgresql/9.1/bin/pg_ctl start -D /home/postgres/data

## STOP DB
$ /usr/lib/postgresql/9.1/bin/pg_ctl stop -D /home/postgres/data -m immediate

::USER ADDING TUTORIAL
http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/

postgresql pgscript

DECLARE @I, @Ts, @node_id; — Variable names begin with a @
SET @node_id = 1;
SET @I = 0; — @I is an integer
WHILE @I < 10000
BEGIN
SET @Ts = 5 * @I;
INSERT INTO table1 values (NOW() – ‘@Ts minute’::INTERVAL, 1,11,0,10.331);
INSERT INTO table2 values (NOW() – ‘@Ts minute’::INTERVAL, 2,11,0,10.331);
SET @I = @I + 1;
END