倒腾oracle 有段时间了。因为项目经常要用到,一些基础的功能还是需要把握的,方便平时项目的对接及维护,实事求是,上图说话,今天记录一个 oracle 11g 完整创建 tablespace 的例子
1.登陆
su - oracel
sqlplus / as sysdba
2.创建用户
create user testuser identified by testuser123;
3.修改密码
alter user testuser identified by testuser123456;
4. 查看用户所在的表空间
select username,default_tablespace from dba_users;
set linesize 300;
set pagesize 30 ;
col USERNAME format a20;
5.创建一个新的表空间
select file_name , tablespace_name from dba_data_files; 查看表空间 的目录位置
create tablespace testuser logging datafile '/opt/oracle/oradata/orcl/orcl_data.dbf' size 50m autoextend on next 50m maxsize 2048m extent management local;
6.将新创建的表空间分配给用户
alter user testuser default tablespace testuser;
7.为用户分配登录权限
grant create session,create table,create view,create sequence,unlimited tablespace to testuser;
select * from all_users;
select * from dba_sys_privs;
SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE = 'TESTUSER'; ####查看该用户具有哪些权限
8.新用户登陆测试
conn testuser/testuser123456
select *from session_privs; ###查看当前用户的权限
9.创建表
create table testnew_IME(id int primary key,name varchar2(10)) segment creation immediate;
select table_name from user_tables where rownum<=3; ###查看该用户具有哪些表
9.删除创建的用户及相关对象
drop user testuser cascade;