How do I add tables to a specific schema in postgreSQL?
tried runnig:
DROP SCHEMA Lab1 CASCADE;
CREATE SCHEMA Lab1;
CREATE TABLE Lab1.PERSONS(
SSN INT primary key,
Name CHARACTER (30),
HouseId INT,
ApartmentNumber INT ,
Salary DECIMAL (5, 2)
);
t=# \dt+ lab1.persons
lab1 | persons | table | postgres | 0 bytes |
As you can see the table is created in lab1 schema. If you want it in Lab1
schema, you should modify your statemet:
t=# DROP SCHEMA "Lab1" CASCADE;
ERROR: schema "Lab1" does not exist
t=# CREATE SCHEMA "Lab1";
CREATE SCHEMA
t=# CREATE TABLE "Lab1".PERSONS(
t(# SSN INT primary key,
t(# Name CHARACTER (30),
t(# HouseId INT,
t(# ApartmentNumber INT ,
t(# Salary DECIMAL (5, 2)
t(# );
CREATE TABLE
t=# \dt+ "Lab1".persons
Lab1 | persons | table | postgres | 0 bytes |