SQL基础(一)之用户与表空间
2015-10-26 21:26
387 查看
用户
查看登录用户
show user 命令 desc dba_users 数据字典中包含的字段
select username from dba_users 查看用户
启用用户 用户名Scott
alter user scott account unlock;
connect scott/tiger
show user 查看现在的用户
表空间
在数据库中开辟的一个空间 用来存数数据
表空间由一个和多个数据文件构成的
永久性表空间
临时表空间(存放数据库操作当中中间执行的过程)
UNdO表空间(被修改以前的数据)
查看用户表空间
dba_tablespaces user_tablespaces数据字典
dba_tablespaces 用于管理员查看表空间
dba_users user_users 数据字典
desc user_tablespaces; 查看表空间命令
select tablespace_name from user_tablespaces;
设置用户的默认或临时表空间
alter user username
default|temporary
tablespace tablespace_name
普通用户没有权限
alter user system
default tablespace syetem;更改表空间
创建表空间
create[temporary] tablespace
tablespace_name
tempfile|datafile
'xx.dbf'size xx
创建永久表空间 临时表空间
create tablespace test1_tablespace
datafile‘test1file,dbf’ size 10m;
(临时表空间)
creater temporary tablespace temptest1_tablespace
tempfile ‘tempfile.dbf’ size 10m;
修改表空间
设置联机 或脱机状态
alter tablespace tablespace_name
online|offline (联机 脱机状态)
desc dba_tablespace 查看状态
select status from dba_tablespaces where tablespace_name='test1_tablespace'
表空间的只读 读写状态
alter tablespace tablespace_name
read only|read write (只读 读写状态)
默认联机状态就是读写状态
修改数据文件
增加数据文件
alter tablespace tablespace_name
add datafile 'xx.dbf' size xx;
删除数据文件
alter tablespace tablespace_name
drop datafile 'xx.dbf' size xx;
删除表空间
drop tablespace
tablespace_name[including contents]
加上后面的代表 除了删除表空间 同时删除表空间的内容\
查看登录用户
show user 命令 desc dba_users 数据字典中包含的字段
select username from dba_users 查看用户
启用用户 用户名Scott
alter user scott account unlock;
connect scott/tiger
show user 查看现在的用户
表空间
在数据库中开辟的一个空间 用来存数数据
表空间由一个和多个数据文件构成的
永久性表空间
临时表空间(存放数据库操作当中中间执行的过程)
UNdO表空间(被修改以前的数据)
查看用户表空间
dba_tablespaces user_tablespaces数据字典
dba_tablespaces 用于管理员查看表空间
dba_users user_users 数据字典
desc user_tablespaces; 查看表空间命令
select tablespace_name from user_tablespaces;
设置用户的默认或临时表空间
alter user username
default|temporary
tablespace tablespace_name
普通用户没有权限
alter user system
default tablespace syetem;更改表空间
创建表空间
create[temporary] tablespace
tablespace_name
tempfile|datafile
'xx.dbf'size xx
创建永久表空间 临时表空间
create tablespace test1_tablespace
datafile‘test1file,dbf’ size 10m;
(临时表空间)
creater temporary tablespace temptest1_tablespace
tempfile ‘tempfile.dbf’ size 10m;
修改表空间
设置联机 或脱机状态
alter tablespace tablespace_name
online|offline (联机 脱机状态)
desc dba_tablespace 查看状态
select status from dba_tablespaces where tablespace_name='test1_tablespace'
表空间的只读 读写状态
alter tablespace tablespace_name
read only|read write (只读 读写状态)
默认联机状态就是读写状态
修改数据文件
增加数据文件
alter tablespace tablespace_name
add datafile 'xx.dbf' size xx;
删除数据文件
alter tablespace tablespace_name
drop datafile 'xx.dbf' size xx;
删除表空间
drop tablespace
tablespace_name[including contents]
加上后面的代表 除了删除表空间 同时删除表空间的内容\