我有这个:
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) );
但是这不起作用,它创建了架构,但是在一个奇怪的地方创建了表,在那里它无法查看(\d+
例如),事实上,我知道它存在的唯一方法就是如果你试图丢弃"lab1"模式会抛出错误,说明lab1正在使用模式.
我尝试设置lab1架构的默认路径: ALTER ROLE -myusername- SET SEARCH_PATH to Lab1?
但这也没有用,\d+
仍然有"人"公开.
那么,我如何将此表放入我想要的模式中?谢谢.
试过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 |
如您所见,该表是在lab1架构中创建的.如果你想在Lab1
架构中使用它,你应该修改你的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 |