Rozdíly
Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.
| Obě strany předchozí revize Předchozí verze Následující verze | Předchozí verze | ||
|
it:postgresql:import_export [2015/09/30 15:15] kourim |
it:postgresql:import_export [2017/06/14 10:55] (aktuální) kourim |
||
|---|---|---|---|
| Řádek 4: | Řádek 4: | ||
| to .psql je ve skutecnosti csv soubor | to .psql je ve skutecnosti csv soubor | ||
| + | <sxh> | ||
| copy(select * from author_roles where attributes->>'activity_Id' != '') to '/tmp/cr_author_roles.psql'; | copy(select * from author_roles where attributes->>'activity_Id' != '') to '/tmp/cr_author_roles.psql'; | ||
| copy(select * from distributors where id = 6) to '/tmp/cr_distributors.psql'; | copy(select * from distributors where id = 6) to '/tmp/cr_distributors.psql'; | ||
| copy(select * from flags where id in (2,6)) to '/tmp/cr_flags.psql'; | copy(select * from flags where id in (2,6)) to '/tmp/cr_flags.psql'; | ||
| + | </sxh> | ||
| ==== Import ==== | ==== Import ==== | ||
| Řádek 23: | Řádek 25: | ||
| </sxh> | </sxh> | ||
| + | ==== Import + Export ==== | ||
| + | vytvoříme dump z aktuální databáze | ||
| + | <sxh bash>pg_dump -U USERNAME DBNAME > dbexport.pgsql</sxh> | ||
| + | přihlásíme se do postgresu | ||
| + | <sxh bash>psql template1</sxh> | ||
| + | vytvoříme uživatele a databázi s právy | ||
| + | <sxh sql> | ||
| + | CREATE USER tom WITH PASSWORD 'myPassword'; | ||
| + | CREATE DATABASE jerry; | ||
| + | GRANT ALL PRIVILEGES ON DATABASE jerry to tom; | ||
| + | </sxh> | ||
| + | nalejeme data do nové databáze | ||
| + | <sxh bash>psql -U USERNAME DBNAME < dbexport.pgsql</sxh> | ||