![]() ![]() 3) Verify the sample databaseįirst, connect to the PostgreSQL server using the psql command: psql -U postgres It’ll take about seconds to load data stored in the dvdrental.tar file into the dvdrental database. Enter the password for the postgres user and press the Enter (or Return key): Password: It’ll prompt you to enter the password for the postgres user. The -d dvdrental specifies the target database to load.The -U postgres instructs pg_restore to connect the PostgreSQL server using the postgres user.Sixth, load the dvdrental database using the pg_restore command: pg_restore -U postgres -d dvdrental D:\ sampledb\ postgres\ dvdrental. Note that other databases such as postgres, template0, and template1 are the system databases.įourth, disconnect from the PostgreSQL server and exit the psql using the exit command: exit Code language: PHP ( php ) 2) Restore the sample database from a tar fileįifth, download the sample database ( dvdrental.zip) and extract the tar file to the directory such as D:\sampledb\postgres\dvdrental.tar on Windows. The output shows that dvdrental on the list, meaning that you have created the dvdrental database successfully. Template1 | postgres | UTF8 | libc | English_United States. ![]() Template0 | postgres | UTF8 | libc | English_United States. Postgres | postgres | UTF8 | libc | English_United States. Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges The \l command will show all databases in the PostgreSQL server: \l Third, verify the database creation using the \l command. PostgreSQL will create a new database called dvdrental. Second, create a new database called dvdrental using CREATE DATABASE statement: CREATE DATABASE dvdrental Code language: SQL (Structured Query Language) ( sql ) The command prompt will look like this: postgres= # Code language: PHP ( php ) The password for the postgres user is the one you entered during the PostgreSQL installation.Īfter entering the password correctly, you will be connected to the PostgreSQL server. It’ll prompt you to enter a password for the postgres user: Password for user postgres: Third, load data from the sample database file into the dvdrental database using pg_restore.įirst, open the Command Prompt on Windows or Terminal on Unix-like systems and connect to the PostgreSQL server using psql tool: psql -U postgres.Second, create a blank database called dvdrental.First, connect to the PostgreSQL database server using psql or pgAdmin.To create a database and load data from an archive file, you follow these steps: Pg_restore is a utility for restoring a database from an archive. It allows you to enter queries, send them to PostgreSQL for execution, and display the results. Psql is a terminal-based client tool to PostgreSQL. Load the sample database using the psql & pg_restore tool A PostgreSQL sample database called dvdrental.Neon Postgres – Fully Automated, Generous Free Tier, Instant DBs, Autoscaling, Git-like Branching - Start Freeīefore going forward with this tutorial, you need to have: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |