转载请注明来源:http://blog.csdn.net/loongshawn/article/details/50458950
相关文章:
1. 查看表空间文件路径
select tablespace_name,file_id,file_name,round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name
2. 新建表空间
创建名为PRO的表空间,初始大小1500M,超过1500M自动增加,每次100M,最大容量10000M。
路径为/opt/oracle/data/data01/rdbms/obak/datafile/obak_pro_01.dbf
create tablespace PRO logging datafile '/opt/oracle/data/data01/rdbms/obak/datafile/obak_pro_01.dbf' size 1500m autoextend on next 100m maxsize 10000m extent management local;
3. 扩展表空间
有时候表空间会不足,需要人为的扩展。这里,我们新建了一个表空间文件obak_pro_03.dbf
ALTER TABLESPACE PRO ADD DATAFILE '/opt/oracle/data/data01/rdbms/obak/datafile/obak_pro_03.dbf' SIZE 1500M AUTOEXTEND ON NEXT 100M MAXSIZE 10000M;
4. 新建用户,绑定表空间
新建用户dba_user,密码abcd1234,所属表空间PRO。
create user dba_user identified by abcd1234 DEFAULT TABLESPACE PRO;
5. 用户赋权
当然,会有权限遗漏,可自行按需添加。
GRANT CREATE SESSION,CREATE ANY TABLE,CREATE ANY VIEW,CREATE ANY INDEX,CREATE ANY sequence,CREATE ANY PROCEDURE, ALTER ANY TABLE,ALTER ANY sequence,ALTER ANY PROCEDURE, DROP ANY TABLE,DROP ANY sequence,DROP ANY VIEW,DROP ANY INDEX,DROP ANY PROCEDURE, SELECT ANY TABLE,INSERT ANY TABLE,UPDATE ANY TABLE,DELETE ANY TABLE TO dba_user;
6. 异常处理
如果出现下述异常:
insert into CAR_BRAND (CB_ID,CB_NAME) values (7,'荣威') ORA-01950: no privileges on tablespace 'USERS' Done. sql>
则表明创建的用户没有表空间的操作权限,需要进行赋权:
ALTER USER dealer QUOTA UNLIMITED ON USERS;
接下来执行数据插入,执行正常!