Postgresql 表空间在pg_表中显示为null
我通过显式传递表空间名称创建了表。但是在签入pg_表和其他pg_表时Postgresql 表空间在pg_表中显示为null,postgresql,Postgresql,我通过显式传递表空间名称创建了表。但是在签入pg_表和其他pg_表时 Create table test1c (Id integer, name varchar(10)) tablespace testts; select * from pg_tables where tablename='test1c'; 它应该显示表空间名称,但将其显示为空默认表空间将不会显示在pg_表中。表空间 包含表的表空间的名称(如果数据库为默认值,则为null) (强调矿山) 如果要查看实际的表空间,需要
Create table test1c (Id integer, name varchar(10)) tablespace testts;
select *
from pg_tables
where tablename='test1c';
它应该显示表空间名称,但将其显示为空默认表空间将不会显示在
pg_表中。表空间
包含表的表空间的名称(如果数据库为默认值,则为null)
(强调矿山)
如果要查看实际的表空间,需要在查询中包括
pg_database
:
select t.schemaname, t.tablename,
coalesce(t.tablespace, ts.default_tablespace) as tablespace
from pg_tables t
cross join (
select ts.spcname as default_tablespace
from pg_database d
join pg_tablespace ts on ts.oid = d.dattablespace
where d.datname = current_database()
) ts
where tablename = 'test1c'
and schemaname = 'public';
testts
可能是数据库的默认表空间吗?是testts是该数据库的默认表空间。