Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

import sql single table dump in postgres

# If you have already created DB then don't need to follow 1st step:-

# STEP=1

# open terminal then run following commands to create postgres database and user:-

sudo -u postgres psql

postgres=# create database mydb;

postgres=# create user myuser with encrypted password 'mypass';

postgres=# grant all privileges on database mydb to myuser;

# STEP=2

# c used for selecting your database.

postgres=# c yourdatabasename

# i used for importing dump data in database.

yourdatabasename=# i path_of_your_dump_file for example:-

yourdatabasename=# i /home/developer/projects/django_projects/db_dump.sql

# If you face this type of error when you importing data:-

# ERROR:  role "yourusername" does not exist

# so you can make superuser to your "db_user/yourusername" using this command:-

postgres=# ALTER USER fusion WITH SUPERUSER;

ALTER ROLE
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #import #sql #single #table #dump #postgres
ADD COMMENT
Topic
Name
2+9 =