管理员用户登录oracle数据库
[oracle@dboracle ~]$ sqlplus / as sysdba
sql*plus: release 11.2.0.4.0 production on tue jan 1 14:59:27 2019
copyright (c) 1982, 2013, oracle. all rights reserved.
connected to:
oracle database 11g enterprise edition release 11.2.0.4.0 – 64bit production
with the partitioning, olap, data mining and real application testing options
sql>
1、创建临时表空间
select name from v$tempfile;查出当前数据库临时表空间,主要是使用里面的存放路径;
得到其中一条记录/u01/oracle/app/oradata/dbprimary/temp01.dbf
创建临时表空间:create temporary tablespace plncontrol_temp tempfile ‘/u01/oracle/app/oradata/dbprimary/plncontrol_temp.dbf’ size 200m reuse autoextend on next 40m maxsize unlimited;
2、创建表空间
select name from v$datafile;查询出当前数据库表空间,使用里面的路径
得到其中一条记录/u01/oracle/app/oradata/dbprimary/system01.dbf
创建表空间:create tablespace plncontrol datafile ‘/u01/oracle/app/oradata/dbprimary/plncontrol.dbf’ size 200m reuse autoextend on next 80m maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);
3、创建用户并指定表空间
create user plncontrol identified by plncontrol default tablespace plncontrol temporary tablespace plncontrol_temp;
4、赋予用户权限
grant connect,resource,dba to plncontrol;
5、查看表空间的名称及大小
select t.tablespace_name, round(sum(bytes / (1024 * 1024)), 0) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name;
6、查看各表空间空闲情况
select tablespace_name, sum(bytes) / 1024 / 1024 from dba_free_space group by tablespace_name;
7、更改数据表大小(2g)
alter database datafile ‘/u01/oracle/app/oradata/dbprimary/webonlinepre.dbf’ resize 2048m;
8、查看表空间是否自动增长
select file_name,tablespace_name,autoextensible from dba_data_files;
9、设置表空间自动增长
alter database datafile ‘/u01/oracle/app/oradata/dbprimary/webonlinepre.dbf’ autoextend on; //打开自动增长
alter database datafile ‘/u01/oracle/app/oradata/dbprimary/webonlinepre.dbf’ autoextend on next 200m; //每次自动增长200m
alter database datafile ‘/u01/oracle/app/oradata/dbprimary/webonlinepre.dbf’ autoextend on next 200m maxsize 2048m; //每次自动增长200m,数据表最大不超过2g