1.系统用户有sys,system,sysman,scott
sys权限高于system,在使用sys登陆数据库的时候要使用管理员或系统操作人员的权限登陆
sysman也是管理员级别的用户
scott是提供给学习者学习的用户(默认密码tiger)
2.show user 命令查看当前用户
dba_users 数据字典 数据字典是数据库提供的表,用来查看数据库信息
desc dba_users查看表信息
3.scott 用户默认是锁定的,登陆前要先解锁
锁定scott用户 alter user scott account lock
解锁scott用户 alter user scott account unlock
在其他用户里解锁scott然后用connect scott/tiger登陆
4.表空间分为 永久表空间 、临时表空间 、UNDO表空间
永久表空间主要存放数据库表、视图、存储过程等,临时表空间主要存放数据库操作的中间执行过程,执行完之后自动释放
查看用户表空间 dba_tablespaces、user_tablespaces 数据字典
dba_users、user_users 数据字典
(desc dba_tablespaces)
5.创建表空间create [temporary]tablespace tablespace_name datafile | tempfile 'xx.dbf' size xx;
查看表空间的具体路径
desc dba_data_files | dba_temp_files
select flie_name from dba_data_files | dba_temp_files where tablespace_name='表空间名字大写';
6.修改表空间
修改表空间的状态
- 联机或脱机 alter tablespace tablespace_name online | offline
- 只读或可读写 alter tablespace tablespace_name read only | read write
-
查看表空间状态 select status from dba_tablespaces where tablespace_name='表空间名字大写'
修改表空间的数据文件
- 增加 alter tablespace tablespace_name add datafile 'xxx.bdf' size xx;
- 删除 alter tablespace tablespace_name drop datafile 'xxx.bdf';(不能删除表空间第一个数据文件)
删除表空间及数据文件 drop tablespace tablespace_name [including contents]