1、使用系统用户登录
sys, system ,sysman 密码是在安装的时候自己设置的
scott 密码默认是tiger
system/passwd 或sys/passwd as sysdba或 connect sys/passwd as sysdba
2、查看登录用户
show user
desc dba_users 查看数据
select username from dba_users; 查看系统用户
connect scott/tiger; 使用scott 登录SQL plus用户
3、表空间操作
表空间的分类:永久表空间,临时表空间,UNDO表空间
1)永久表空间: 永久存储的表/视图等
2)临时表空间: 数据库操作中中间执行的过程, 完了自行删除将不永久保存
3)UNDO表空间: 保存事务所修改的旧值,修改前的数据(利于撤销等方便回滚)
system用户的默认表空间和临时表空间分别是system ,temp
(1)查看
desc tablespaces 查看表空间
select tablespace_name from dba_tablespaces; 查看
dba_tablespaces表空间
(2) 查看与更改
alter user system default tablespace system; 更改默认表空间
select default_tablespace, temporary_tablespace from dba_users where username=”SYSTEM”;查看
(3) 创建与删除
create tablespace test1_tablespace datafile ‘test1_file.dbf’ size 10m; 创建永久表空间
drop tablespace test1_tablespace including contents; 删除表空间
(4)添加与删除表空间文件
alter tablespace test1_tablespace add datafile ‘test2_file.dbf’ size 10m; 往表空间中添加数据文件
alter tablespace test1_tablespace drop datafile ‘test2_file.dbf’ ; 往表空间中删除数据文件
select file_name from dba_data_files where
tablespace_name=’TEST1_TABLESPACE’; 查看