oracle基础-用户与表空间

系统用户

sys–超级用户
system–管理员用户
sysman–操做企业管理器
scott–Oracle创始人的名字web

用sqlplus登陆

system/orcl@127.0.0.1:1521sql

查看登陆用户

show user

解锁/锁定用户

alter user username account unlock/lock

表空间

–永久表空间(表,视图,存储过程)
–临时表空间(中间执行过程)
–UNDO表空间(事务修改前的数据)bash

查看用户表空间

desc dba_tablespaces; 查询表空间
select tablespce_name from dba_tablespaces;
desc user_tablespaces;查询普通用户表空间

设置用户表空间

alter user system default tablespace system;
设置用户system的默认表空间为system;

建立表空间

create [temporary] tablespace tablespace_name tempfile|datafile 'xx.dbf' size xx;
建立表空间语句
eg:
create tablespace test datafile 'testfile.dbf' size 10m;建立永久性表空间
create temporary tablespace test tempfile 'testfile.dbf' size 10m;建立临时表空间
select file_name from dba_data_files where tablespace_name='TEST';查看表空间文件路径

修改表空间状态

select status from dba_tablespaces where tablespace_name='test';查看表空间状态
alter tablespace test offline/online;修改表空间离线/在线状态;
alter tablespace test read only/read write;修改表空间只读/读写状态;

修改数据文件

alter tablespace table_name add datafile 'xx.dfb' size xx;增长数据文件
alter tablespace table_name drop datafile 'xx.dfb' size xx;删除数据文件

删除表空间

drop tablespace table_name [including contents]
删除表空间 [删除数据文件]