postgresql learning notes
作者: 2hei 发表于2011年1月 4日 18:07 版权声明: 可以转载, 转载时务必以超链形式标明文章原始出处和作者信息及版权声明
http://www.2hei.net/mt/2011/01/postgresql-learning-notes.html
1.Host Access file:
/var/lib/pgsql/data/pg_hba.conf
host all all 172.16.1.0/24 md5
2.logon postgresql
su - postgres
$psql
or $psql -U postgres -h 127.0.0.1
postgres=# create user "2hei" with password 'pwd' nocreatedb;
postgres=# create database "test_db" with owner="2hei";
\lu
\q
3.test link
linux:
psql -U 2hei -h 172.16.1.100
windows
D:/soft/postgresql9/bin/psql.exe -h 172.16.1.100 -U 2hei -d test_db -p 5432 -c "\l"
4.set sys env (linux/windows)
PGPASSWORD
hostname:port:database:username:password
5copy without pwd:
D:\soft\postgresql9\bin\psql.exe -h localhost -U 2hei -d test_db -p 5432 -c "COPY test_tb(name,desc,comm1,comm2) FROM 'D:/upload.txt' WITH DELIMITER ',' NULL AS '' csv;"
cat upload.txt
1,2,3,4
2,3,4,5
------------
/var/lib/pgsql/data/pg_hba.conf
host all all 172.16.1.0/24 md5
2.logon postgresql
su - postgres
$psql
or $psql -U postgres -h 127.0.0.1
postgres=# create user "2hei" with password 'pwd' nocreatedb;
postgres=# create database "test_db" with owner="2hei";
\lu
\q
3.test link
linux:
psql -U 2hei -h 172.16.1.100
windows
D:/soft/postgresql9/bin/psql.exe -h 172.16.1.100 -U 2hei -d test_db -p 5432 -c "\l"
4.set sys env (linux/windows)
PGPASSWORD
hostname:port:database:username:password
5copy without pwd:
D:\soft\postgresql9\bin\psql.exe -h localhost -U 2hei -d test_db -p 5432 -c "COPY test_tb(name,desc,comm1,comm2) FROM 'D:/upload.txt' WITH DELIMITER ',' NULL AS '' csv;"
cat upload.txt
1,2,3,4
2,3,4,5
------------





发表一个评论