uxdb用户登录,创建表空间和属于该表空间的测试表:
create tablespace myspace location '/home/uxdb/'; create table testspace (id1 int,id2 int) tablespace myspace;
查看修改表空间资源限额:
select spcname, ux_size_pretty(ux_tablespace_size(spcname)) from ux_tablespace; alter tablespace myspace set (max_space_size='10M');
重启数据库使上述配置生效。
uxdb用户登录查看最大表空间限制和阈值:
select spcoptions from ux_tablespace where spcname='myspace'; show ts_size_threshold;
最大表空间限制为10M。
阈值为0.8。
创建一次插入10W数据的存储过程:
create or replace function insert_test() returns boolean as $body$ declare ii integer; begin ii:=1; for ii in 1..100000 loop insert into testspace(id1, id2) values (116, ii); end loop; return true; end; $body$ language pluxsql;
多次执行上述存储过程插入数据,使数据大于10M:
select insert_test();
可以看到,当存储达到表空间大小阈值的时候,给出警告WARNING: Tablespace myspace(10473472) exceeds size threshold(0.8*10485760)。当存储超过表空间大小时,会发出错误告警FATAL: insufficient disk space or tablespace,且数据库会重新连接。