当前位置: 首页 > database > 正文

postgresql learning notes

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
————

本文固定链接: http://2hei.net/postgresql_learning_notes.html | 2hei's site

该日志由 2hei 于2011年01月04日发表在 database 分类下,
原创文章转载请注明: postgresql learning notes | 2hei's site
关键字:

报歉!评论已关闭.