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
————
本文固定链接: https://www.2hei.net/2011/01/04/postgresql_learning_notes/ | 2hei.net
最活跃的读者