表空间:
数据库的逻辑存储空间,可以理解为在数据库中开辟的空间用来存储数据库对象;
表空间数据文件:
表空间由一个或多个数据文件构成。
分类:
tableapce:永久表空间,保存数据库需要永久保存的对象,如表、视图、存储过程。
temporary tablespace:临时表空间,存储数据库操作过程中需要保存的文件,操作完成以后就会被释放
undo tablespace:重做表空间,用来保存数据库操作过程中修改的旧值,用来回滚事务。
准备:
在SqLPlus命令窗口下:
输入:con sys/cl123456
---->进入系统用户
其中,cl123456是安装oracle我设置的系统用户密码
1.创建表空间:表空间名为test1_tablespace 其中的数据文件为test1file.dbf,大小10m
create tablespace test1_tablespace datafile 'test1file.dbf' size 10m;
2.创建临时表空间:
create temporary tablespace temptest1_tablespace tempfile 'tempfile1.dbf' size 10m
oracle提供系统用户查看表空间的的数据字典:
dba_data_files :存储和永久表空间
dba_temp_files :存储临时表空间
查看表空间:
select file_name from dba_data_files where tablespace_name='TEST1_TABLESPACE';
查看临时表空间:
select file_name from dba_temp_files where tablespace_name='TEMPTEST1_TABLESPACE';
创建用户并指名表空间和临时表空间:
在sys下创建:用户名yan;密码test;表空间:test1_tablespace;临时表空间:temptest1_tablespace;
create user yan identified by test default tablespace test1_tablespace temporary tablespace temptest1_tablespace;
***如果为用户不指名表空间,则默认使用系统空间为用户创建,会造成问题。
查看所有用户:
select username from dba_users;
- 授权:grant connect to yan;
- 连接到yan:conn yan/test
- 更改初始密码:alter user yan identified by t123;
- 锁定用户使其无法登录:使用sys连接后,alter user yan account lock;
- 删除用户:drop user yan cascade;(cascade级联删除该用户创建的所有东西)