Created
April 30, 2018 05:08
-
-
Save stephenquan/f6fc9406765615b30fc15f8f18754710 to your computer and use it in GitHub Desktop.
psql_demo.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demonstrates psql command line client on Ubuntu machines | |
# See: https://www.postgresql.org/download/linux/ubuntu/ | |
cat $HOME/.pgpass <<EOF | |
$PGHOST:5432:$PGINST:$PGUSER:$PGPASS | |
EOF | |
psql -h $PGHOST -p 5432 -U $PGUSER $PGINST -t -f - <<EOF | |
drop table primes; | |
create table primes ( | |
num int not null primary key, | |
txt text | |
); | |
insert into primes values (2, 'two'); | |
insert into primes values (3, 'three'); | |
insert into primes values (5, 'five'); | |
insert into primes values (5, 'lima') on conflict (num) do update set txt = 'lima'; | |
select * from primes; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment