Difference between revisions of "PostgreSQL"

(pg_dump)
Line 4: Line 4:
 
<pre>
 
<pre>
 
psql -h <HOST> -U <USERNAME> -w -d <DBNAME>
 
psql -h <HOST> -U <USERNAME> -w -d <DBNAME>
psql -h 127.0.0.1 -U elugy -d elugy_portal
+
psql -h localhost -U elugy -d elugy_portal
 
</pre>
 
</pre>
  
 
=== Parancs futtatása: ===
 
=== Parancs futtatása: ===
 
<pre>
 
<pre>
psql -h 127.0.0.1 -U elugy -d elugy_portal -c "select count(1) from parameter;"
+
psql -h localhost -U elugy -d elugy_portal -c "select count(1) from parameter;"
 
</pre>
 
</pre>
  
Line 15: Line 15:
  
 
<pre>
 
<pre>
psql -h 127.0.0.1 -U elugy -W -d elugy_portal -f test.sql
+
psql -h localhost -U elugy -W -d elugy_portal -f test.sql
psql -h 127.0.0.1 -U elugy -W -d elugy_portal < test.sql
+
psql -h localhost -U elugy -W -d elugy_portal < test.sql
 
</pre>
 
</pre>
  
Line 27: Line 27:
  
 
<pre>
 
<pre>
pg_dump -b -d elugy_portal -h 127.0.0.1 -U elugy -W > elugy.sql
+
pg_dump -b -d elugy_portal -h localhost -U elugy -W > elugy.sql
pg_dump --blobs --dbname elugy_portal --host 127.0.0.1 --username elugy --password > elugy.sql
+
pg_dump --blobs --dbname elugy_portal --host localhost --username elugy --password > elugy.sql
 
</pre>
 
</pre>
  
Line 34: Line 34:
  
 
<pre>
 
<pre>
createdb -h 127.0.0.1 -U elugy -W -O elugy testdb
+
createdb -h localhost -U elugy -W -O elugy testdb
createdb --host 127.0.0.1 --username elugy --password --owner elugy testdb
+
createdb --host localhost --username elugy --password --owner elugy testdb
 
</pre>
 
</pre>
  

Revision as of 14:24, 29 October 2018

psql

Csatlakozás:

psql -h <HOST> -U <USERNAME> -w -d <DBNAME>
psql -h localhost -U elugy -d elugy_portal

Parancs futtatása:

psql -h localhost -U elugy -d elugy_portal -c "select count(1) from parameter;"

SQL fájl futtatása, dump betöltés:

psql -h localhost -U elugy -W -d elugy_portal -f test.sql
psql -h localhost -U elugy -W -d elugy_portal < test.sql

Csatlakozás utáni parancsok:

  • \l vagy \list: adatbázisok listázása
  • \q vagy \quit: kilépés

pg_dump

pg_dump -b -d elugy_portal -h localhost -U elugy -W > elugy.sql
pg_dump --blobs --dbname elugy_portal --host localhost --username elugy --password > elugy.sql

createdb

createdb -h localhost -U elugy -W -O elugy testdb
createdb --host localhost --username elugy --password --owner elugy testdb

Vagy PSQL paranccsal való csatlakozás után a konzolon:

create database testdb owner elugy;

createuser