How to import a schema sql file using pgadmin 4?
Asked Answered
H

4

22

Is it possible? If so how?

I can only find solution for pgadmin 3 which doesn't work for me.

Harmful answered 27/7, 2018 at 22:4 Comment(0)
C
35

It worked like this for me:

  1. Go to your Database and click on this.
  2. Click in the menubar on Tools, Query Tools

enter image description here

  1. Then it reload the page. Above the menubar on the left, you see the folder-icon (look picture below). Click on them and choose your .sql file
  2. Click on select and the file is uploaded
  3. To execute the .sql file, press F5 or the play button above the menubar in the middle (look at the screenshot below).
  4. Right click on your database and click on 'Refresh'.

enter image description here

Cogitative answered 3/6, 2020 at 14:34 Comment(2)
I'm importing the sql file like as the answer mentioned above but it says File type not supported. my file is like test.sql.Ultann
file is huge. impossible to open it in an editor. how to execute file? not how to copy-paste in sql inputWillie
C
10

Following are the step that will help you in importing all tables of your schema

1) Open pgAdmin 4

2) Navigate to Your Database Name --> Schemas --> public

3) Then right click on public

4) After clicking on public then select Restore option from DropDown Menu

5) A window will open in which you only have to give location of .sql file and leave other textboxes

6) Click Restore and leave rest on pgadmin

Note : You have to perform these steps for every single table you want to import

Camarilla answered 13/8, 2018 at 19:6 Comment(2)
if it did not work try using pgsql Shell enter your server and database and user information then run without any quotes \i D:/folder/your_table.sqlNoelyn
In my case, DB already had data, and restore failed. To resolve it I dropped DB and created a new one assigning the same user which is used for backup. Then the answer worked for me.Ashton
L
2

To handle this problem, follow these steps:

  1. Select your Database.
  2. Click in the menubar, select Tools & Query Tools,
  3. Import your SQL (to generate query create table)
  4. Execute query
Lateshalatest answered 17/11, 2020 at 4:11 Comment(0)
E
0

To import a schema SQL file using pgAdmin 4, follow these steps:

Open pgAdmin 4:

Launch pgAdmin 4 from your applications or start menu.

Connect to Your Database:

In the pgAdmin 4 interface, connect to your PostgreSQL server if you haven't already by clicking on the server name in the left-hand panel and entering your connection details.

Select the Database:

In the left-hand tree view, expand the server and then expand the Databases section. Select the database where you want to import the schema.

Open Query Tool:

Right-click on the selected database, navigate to Tools, and then click on Query Tool. Alternatively, you can click on the database and then use the Query Tool button in the toolbar. Load the SQL File:

In the Query Tool window, click on the Open File button (folder icon) in the toolbar. Browse to and select the SQL file containing your schema.

Execute the SQL File:

Once the file is loaded into the Query Tool, you will see the SQL commands in the editor window. Click the Execute/Refresh button (lightning bolt icon) in the toolbar to run the SQL commands.

Verify the Schema:

After the execution completes, check the Messages tab at the bottom of the Query Tool to ensure there are no errors. You can also refresh your database schema tree in the left-hand panel to see the newly imported schema objects.

Emergency answered 23/5, 2024 at 8:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.