oracle新建用户相关操作
查看用户及表空间
select username,default_tablespace from dba_users;
–查看表空间 USERS 信息
select t.* from sys.dba_data_files t where t.tablespace_name ='USERS';
查询当前数据库中表空间SEC_D是否为自动扩展
select tablespace_name,file_name,autoextensible from dba_data_files where tablespace_name = 'SEC_D';
通过修改SEC_D的数据文件为自动扩展达到表空间SEC_D为自动扩展的目的
alter database datafile '/u01/app/oracle/oradata/orcl/sec_d01.dbf' autoextend on;
新建表空间:
create tablespace NEW_TABLESPACENAME datafile ‘dir’ size 1024M reuse;
还有一种方法是在创建表空间的设置自增加属性,这样在表空间不足的时候会自己增加,这是一种比较合理的策略
create tablespace NEW_TABLESPACENAME datafile 'dir' size 1M autoextend on next 50M maxsize unlimited;
autoextend 自动增长 50M是自增的大小
例如:
create tablespace test_db_data datafile 'test_db_data.dbf' size 10240M autoextend on next 2048M maxsize unlimited;
–删除用户:
drop user USERNAME cascade;
cascade:删除用户下的所有数据
–新建用户
create user USERNAME identified by " PASSWORD" default tablespace TABLESPACENAME
profile DEFAULT ACCOUNT UNLOCK;
–给新建用户授DBA权限
grant create session to NEW_USERNAME;
grant dba to NEW_USERNAME;
grant unlimited tablespace to NEW_USERNAME;