每个用户都有默认永久表空间和默认临时表空间。用户创建的任何模式对象将保存在默认永久表空间中,除非在创建对象时指定另一个表空间,否则对象将创建在默认表空间中。包括系统用户在内,所有用户都有默认临时表空间。在执行某些操作时(如排序,联接表,临时表等),PGA不能满足需要的空间量便会使用临时表空间。
永久表空间
系统的默认表空间可以在DATABASE_PROPERTIES试图中查看,并使用ALTER DATABASE DEFAULT TABLESPACE tablespace1 修改系统默认永久表空间,在创建用户时未指定用户默认表空间时,则会使用使用DATABASE_PROPERTIES中的DEFAULT_PERMANENT_TABLESPACE为用户的默认表空间。
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069496gijJ.png?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069567L9E6.png?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_14970695672W8w.png?x-oss-process=style/bb)
也可以在创建用户时指定用户永久表空间,或者在创建后更改用户永久表空间。
CREATE USER user1 IDENTIFIED BY password DEFAULT TABLESPACE tbs1
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069568YZ4c.png?x-oss-process=style/bb)
ALTER USER user1 DEFAULT TABLESPACE tbs1;
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_14970695687yUr.png?x-oss-process=style/bb)
临时表空间
使用ALTER DATABASE TEMPORARY TABLESPACE temp1来修改系统默认临时表空间。
使用create temporary tablespace temp1 tempfile ‘dir1’ size 2000m创建一个临时表空间并在此更改系统默认临时表空间。
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069569y7Iw.png?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069569nc05.png?x-oss-process=style/bb)
不指定默认临时表空间创建用户后,临时表空间已更改为temp1。
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069569qAsL.png?x-oss-process=style/bb)
也可以在创建用户时指定用户临时表空间或者在创建后更改用户临时表空间
CREATE USER user1 IDENTIFIED BY password TEMPORARY TABLESPACE temp1;
ALTER USER user1 TEMPORARY TABLESPACE temp;
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_1497069569BQJE.png?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201706/10/31461640_149706957010Mm.png?x-oss-process=style/bb)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31461640/viewspace-2140570/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31461640/viewspace-2140570/