postgresql - 表空间在 pg_tables 中显示为空
问题描述
我通过显式传递表空间名称来创建表。但是在检查 pg_tables 和其他 pg_ 表时
Create table test1c (Id integer, name varchar(10)) tablespace testts;
select *
from pg_tables
where tablename='test1c';
它应该显示表空间名称,但显示为空
解决方案
默认表空间不会显示在pg_tables.tablespace
包含表的表空间的名称(如果数据库默认为 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';
推荐阅读
- type-conversion - 在 Ada 中,如何将 64 位浮点数分配给 16 位整数导致代码失败?
- github - “git log”中的电子邮件地址错误
- python - 枚举澄清
- reactjs - 如何在 React 中使用 Redux 将多个状态映射到 props?
- r - R:对 data.frame 使用 ifelse?
- java - 如何在 lambda 表达式中从另一个对象设置一个对象
- mysql - 具有多个AND条件的mysql连接查询
- python - compare_faces 返回所有 True 值(face_recognition 库)
- c++ - 数组中的最大值和出现次数
- jquery - jquery - 附加一个按钮,然后想使用 jquery 事件