Skip to content

iamankr/leetcode-sql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leetcode-sql

Repository Contains :

(1) 120+ Leetcode SQL Question Solutions
(2) PostgreSQL Dump File (leetcodedb.sql)

How to Import dump file using command line terminal?

(1) Open terminal & open psql utility

user@my-machine:~$ psql

(2) Create Database (To import the dump file, database should be created priorly)

postgres=# CREATE DATABASE sample_db;

(3) Quit the psql promt

postgres=# \q

(4) From terminal, Load dump file into the newly created database using below command

user@my-machine:~$ pg_restore --host "127.0.0.1" --port "5432" --username "postgres" --dbname "sample_db" --verbose "leetcodedb.sql"

How to Import dump file using PgAdmin tool?

(1) Open PgAdmin & Create Database

Servers -> Databases -> Create -> Database.. (Create Database dialog will get opened)

(2) Restore Dump File

Right Click on newly created Database & select Restore option from menu (Restore dialog will get opened)

Just Browse the dump file and keep other options as it is.

Notes :

(1) Do not just copy-paste and run the content of dump file into either "psql promt in terminal" or "query tool of pgadmin".
(Because dump file contains COPY commands not INSERTS,So doing such will cause errors.)
(2) Replace your configurations(host,port,username) in pg_restore command
(3) Table names are suffixed with question number.
(4) New solutions will get added as I solve them.

About

Leetcode SQL Solutions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published