PostgreSQL – How to Create a Table Inside the Selected Database

postgresqlpostgresql-10table

This is the command to create a new database,

CREATE DATABASE mydb;

This is the command to create a new table,

CREATE TABLE IF NOT EXISTS mytable ( int a PRIMARY KEY );

But this does not add the mytable inside the mydb. How to add the table inside the database mydb?

Best Answer

But this does not add the mytable inside the mydb. How to add the table inside the database mydb?

You have to connect to the database mydb,

psql -d mydb

Then run the command