📄 tablespace.source
字号:
-- create a tablespace we can useCREATE TABLESPACE testspace LOCATION '@testtablespace@';-- create a schema we can useCREATE SCHEMA testschema;-- try a tableCREATE TABLE testschema.foo (i int) TABLESPACE testspace;SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c where c.reltablespace = t.oid AND c.relname = 'foo'; relname | spcname ---------+----------- foo | testspace(1 row)INSERT INTO testschema.foo VALUES(1);INSERT INTO testschema.foo VALUES(2);-- indexCREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace;SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c where c.reltablespace = t.oid AND c.relname = 'foo_idx'; relname | spcname ---------+----------- foo_idx | testspace(1 row)-- Will fail with bad pathCREATE TABLESPACE badspace LOCATION '/no/such/location';ERROR: could not set permissions on directory "/no/such/location": No such file or directory-- No such tablespaceCREATE TABLE bar (i int) TABLESPACE nosuchspace;ERROR: tablespace "nosuchspace" does not exist-- Fail, not emptyDROP TABLESPACE testspace;ERROR: tablespace "testspace" is not emptyDROP SCHEMA testschema CASCADE;NOTICE: drop cascades to table testschema.foo-- Should succeedDROP TABLESPACE testspace;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -