CM2908 Leetcode Sql Save

Leetcode SQL Solutions

Project README

Leetcode SQL Questions & Solutions

alt text

Repository Contains :

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

Problem statements of all questions including leetcode premium questions :

(1) https://leetcode.ca
(2) https://lifewithdata.com/sql
(3) https://www.jiakaobo.com/leetcode

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"

Replace your configurations(host,port,username) in pg_restore command

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) Table names are suffixed with question number.
(3) New solutions will get added as I solve them.

Checkout my another repository which cantains Miscellaneous SQL Questions & Solutions :

https://github.com/cM2908/misc-sql

Checkout my Blogs on interesting SQL topics :

http://chintan-sql.blogspot.com

Open Source Agenda is not affiliated with "CM2908 Leetcode Sql" Project. README Source: cM2908/leetcode-sql

Open Source Agenda Badge

Open Source Agenda Rating