SYS@orcl> prompt delete the ntbs tablespace if exists.
delete the ntbs tablespace if exists.
SYS@orcl> drop tablespace ntbs including contents and datafiles;
drop tablespace ntbs including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'NTBS' does not exist
SYS@orcl> prompt starting create tablespace ntbs
starting create tablespace ntbs
SYS@orcl> create smallfile tablespace ntbs
2 datafile '/u01/app/oracle/oradata/orcl/ntbs01.dbf'
3 size 100M
4 reuse
5 autoextend on next 10M
6 maxsize 200M
7 logging
8 extent management local
9 autoallocate -- autoallocate
10 segment space management auto
11 default nocompress;
Tablespace created.
SYS@orcl> prompt create user tt
create user tt
SYS@orcl> create user tt identified by tt default tablespace ntbs;
User created.
SYS@orcl> grant connect,resource to tt;
Grant succeeded.
SYS@orcl> connect tt/tt
Connected.
TT@orcl> set echo on
TT@orcl> create table tb1(c1 date);
Table created.
TT@orcl> connect / as sysdba
Connected.
SYS@orcl> set echo on
SYS@orcl> select extent_id,file_id,bytes/1024 byte_kb from dba_extents
2 where segment_name = 'TB1' and wner='TT';
no rows selected
SYS@orcl> alter table tt.tb1 allocate extent;
Table altered.
SYS@orcl> select extent_id,file_id,bytes/1024 bytes_kb from dba_extents
2 where segment_name='TB1' and wner='TT';
EXTENT_ID FILE_ID BYTES_KB
---------- ---------- ----------
0 11 64
1 11 64
2 rows selected.
SYS@orcl>
SYS@orcl> drop user tt cascade;
User dropped.
SYS@orcl> drop tablespace ntbs including contents and datafiles;
Tablespace dropped.
SYS@orcl>
SYS@orcl> prompt testing for uniform
testing for uniform
SYS@orcl> create smallfile tablespace ntbs
2 datafile '/u01/app/oracle/oradata/orcl/ntbs01.dbf'
3 size 100M
4 reuse
5 autoextend on next 10M
6 maxsize 200M
7 logging
8 extent management local
9 uniform. size 128K --uniform
10 segment space management auto
11 default nocompress;
Tablespace created.
SYS@orcl> create user ttt identified by ttt default tablespace ntbs;
User created.
SYS@orcl> grant connect,resource to ttt;
Grant succeeded.
SYS@orcl> connect ttt/ttt
Connected.
TTT@orcl> set echo on
TTT@orcl> create table tb1 (c1 date);
Table created.
TTT@orcl> connect / as sysdba
Connected.
SYS@orcl> set echo on
SYS@orcl> select extent_id,file_id,bytes/1024 bytes_kb from dba_extents
2 where segment_name = 'TB1' and wner='TTT';
no rows selected
(注:由于非sys/system用户表创建时区间分配的延迟性,所有没有返回行。)
SYS@orcl> alter table ttt.tb1 allocate extent;
Table altered.
SYS@orcl> select extent_id,file_id,bytes/1024 bytes_kb from dba_extents
2 where segment_name = 'TB1' and wner='TTT';
EXTENT_ID FILE_ID BYTES_KB
---------- ---------- ----------
0 11 128
1 11 128
2 rows selected.
(注: 由于非sys/system用户表创建时区间分配的延迟性,加上为表再分配一个区间,则返回两行)
SYS@orcl> drop user ttt cascade;
User dropped.
SYS@orcl> drop tablespace ntbs including contents and datafiles;
Tablespace dropped.
SYS@orcl> spool off
注意:sys/system用户创建表时不带区间分配延迟性:
OC@orcl> conn / as sysdba
Connected.
SYS@orcl> show user
USER is "SYS"
SYS@orcl> create table dd(c1 date) tablespace fsdata;
Table created.
SYS@orcl> select extent_id,file_id,bytes/1024 bytes_kb from dba_extents where wner='SYS' and segment_name = 'DD';
EXTENT_ID FILE_ID BYTES_KB
---------------- ---------- ----------
0 8 64
1 row selected.
SYS@orcl> alter table dd allocate extent;--手动添加区间
Table altered.
SYS@orcl> select extent_id,file_id,bytes/1024 bytes_kb from dba_extents where wner='SYS' and segment_name = 'DD';
EXTENT_ID FILE_ID BYTES_KB
---------- ---------- ----------
0 8 64
1 8 64
2 rows selected.
SYS@orcl>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27795363/viewspace-745355/
,如需转载,请注明出处,否则将追究法律责任。