2.创建一张表
CREATE TABLE testemp AS SELECT * FROM emp;
3.查询testemp表段相关的逻辑结构
SELECT t.segment_name,
t.tablespace_name,
t.extents,
t.initial_extent,
t.next_extent,
t.max_extents,
t.blocks
FROM User_Segments t
WHERE t.segment_name ='TESTEMP';
5.在创建表空间时,segment的管理方式最好使用AUTO
create smallfile tablespace satbs
datafile '/opt/oracle/app/oradata/orcl/satbs01.dbf' size 100m
autoextend on next 1m maxsize unlimited logging
segment space management auto
extent management local uniform size 1m;
6.通过dba_tablespaces来验证satbs的相关参数
select tablespace_name,
status,
logging,
segment_space_management,
extent_management
from dba_tablespaces t
WHERE tablespace_name ='SATBS';
8.查看表空间是否创建
select tablespace_name,
status,
logging,
segment_space_management,
t.EXTENT_MANAGEMENT
from dba_tablespaces t
WHERE tablespace_name ='USER_DATA';
9.查看表空间user_data对应的数据文件
select file_id,
file_name,
tablespace_name,
status
from dba_data_files
where tablespace_name ='USER_DATA';
10.表空间磁盘管理的两种方案
1.数据字典管理的表空间磁盘管理
2.本地管理的表空间磁盘管理
11.表空间的分类
1.永久表空间
2.临时表空间
3.还原表空间
12.通过数据字典查询表空间的类型
select distinct (contents) from dba_tablespaces;
13.查询当前数据库的默认永久表空间
SELECT t.property_value
FROM Database_Properties t
WHERE t.property_name ='DEFAULT_PERMANENT_TABLESPACE';
14.修改默认的永久表空间
alter database default tablespace users;
15.查询当前的默认临时表空间
select property_value
from database_properties t
where t.property_name ='DEFAULT_TEMP_TABLESPACE';
16.创建表空间
创建数据字典管理的表空间
create tablespace tianjin_data
datafile '/opt/oracle/app/oradata/orcl/tianjindata01.dbf' size 100m
minimum extent 20k
extent management dictionary
default storage
(initial 20k next 20k maxextents 500 pctincrease 0)
create tablespace tianjin_data
*
ERROR at line 1:
ORA-12913: Cannot create dictionary managed tablespace
问题:
ORA-12913 Cannot create dictionary managed tablespace
Cause: An attempt was made to create a dictionary managed tablespace in a database whose SYSTEM tablespace is locally managed.
Action: Create a locally managed tablespace.
该信息告诉我们只能在SYSTEM表空间为字典管理时才能用以上语句创建字典管理的表空间。
DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_FROM_LOCAL
DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL
execute DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_FROM_LOCAL('SYSTEM');
也不行的。
结论:
如果你想在SYSTEM为本地管理表空间的数据库上建立字典管理的表空间,那么答案是 no way!!!
17.验证创建表空间
select tablespace_name,
extent_management,
status
from dba_tablespaces;
19.验证表空间的区段管理方式
select tablespace_name,
extent_management,
status,
block_size
from dba_tablespaces
where tablespace_name ='BEIJING_DATA';
20.验证表空间的数据文件信息
select tablespace_name,
file_name,
status
from dba_data_files
where tablespace_name ='BEIJING_DATA';
21.查看本地管理的表空间的存储参数信息
select tablespace_name,
block_size,
initial_extent,
next_extent,
max_extents,
pct_increase
from dba_tablespaces t
where tablespace_name ='BEIJING_DATA';
文章目录前言一、永久表空间二、实验前言一、永久表空间二、实验1.查询当前数据块的大小SQL> show parameter db_block_size;2.创建一张表CREATE TABLE testemp AS SELECT * FROM emp;3.查询testemp表段相关的逻辑结构SELECT t.segment_name, t.tablespace_name, t.extents, t.initial_extent,