--查看表空间select*from v$tablespace;--查看表空间中的数据文件desc dba_data_files;--在Command Window中运行--查看详细的数据文件select file_name,tablespace_name from dba_data_files;--查询SYSTEM用户的默认表空间 eg:用户名称要大写select default_tablespace from dba_users where username='SYSTEM';--查询SCOTT用户的默认表空间select default_tablespace from dba_users where username='SCOTT';--查询SYSTEM用户的临时表空间select Temporary_tablespace from dba_users where username='SYSTEM';--查询SCOTT用户的临时表空间select Temporary_tablespace from dba_users where username='SCOTT';--查询永久表空间select property_name,property_value from database_properties;--老师为1条记录,我是13条--查询普通用户拥有的表空间select username,temporary_tablespace from dba_users;--查询当前用户拥有的表空间---不同的用户会使用不同的表空间desc dba_tablespaces;--Command Window--创建表空间 第一章PPT第35张---创建表空间的语法:----create tablespace 表空间 datafile'指定数据文件的位置' size 大小(autoextend on 表空间不够自动增长 next 设置自动大小)-----创建一个名为crm的表空间createtablespace tab_sp_crm datafile'D:\crm.dbf' size 100M;--查询当前用户select username,temporary_tablespace from dba_users;select*from dba_data_files where file_name='tab_sp_crm';--创建一个名为crms的临时表空间 在create后添加temporary,数据文件使用tempfilecreatetemporarytablespace tab_sp_crms tempfile'D:\crms.dbf' size 100M;-- 查看表空间的具体路径desc dba_data_files;--在Command Window中运行select file_name,tablespace_name from dba_data_files;--设置用户的默认或临时表空间(普通用户没有设置表空间的权限)---语法:alter user username default|temporary tablespace tablespace_name;---将tab_sp_crms临时表空间指定给SCOTT用户alteruser scott temporarytablespace tab_sp_crms;--查询SCOTT用户的临时表空间select Temporary_tablespace from dba_users where username='SCOTT';-- 添加数据文件---<1>如果是给已存在的表空间添加数据文件,则使用:----alter tablespace 表空间名称 add datafile'数据文件名称' size 大小;altertablespace tab_sp_crm add datafile'D:\crmadd.dbf' size 50M;---<2>新建表空间的时候同时添加数据文件----create tablespace 表空间 datafile'指定数据文件的位置' size 大小;--练习:---创建一个名为tab_sp_student的表空间,并添加名为student.dbf的数据文件createtablespace tab_sp_student datafile'D:\student.dbf' size 50M;----给已创建好的tab_sp_student表空间添加一个名为student2.dbf的数据文件altertablespace tab_sp_student add datafile'D:\student2.dbf' size 50M;---创建一个名为tab_sp_student3的临时表空间并添加名为student3.dbf的数据文件并将这个表空间指定给scott用户createtemporarytablespace tab_sp_student3 tempfile'D:\student3' size 100M;alteruser scott temporarytablespace tab_sp_student3;--删除表空间---语法:drop tablespace 表空间名称 including contents and datafiles---删除SCOTT用户的临时表空间tab_sp_crms;droptablespace tab_sp_crms including contents and datafiles;droptablespace tab_sp_student3 including contents and datafiles;--重命名表空间---语法:alter tablespace 原表空间名称 rename 新表空间名称;