administrando tablespaces and datafiles
TRANSCRIPT
-
7/26/2019 Administrando Tablespaces and datafiles
1/10
Administrando Tablespaces y Datafiles
1Crear un tablespace permanente con el siguiente nombre y almacenamiento:
a.DATA01administrado por el diccionario de datos.
SQL>CREATE TABLESPACE data01
23
DATAFILE 'D:\ORACLASS\ORADATA\u04\data01.dbf' SIZE 2MEXTENT MANAGEMENT DICTIONARY;
No se puede crear.
b.DATA02administrado localmente con tamao de extents uniformes. Asegrese quecada tamao de extent usado en el tablespace sea un mltiplo de 100 KB.
SQL>CREATE TABLESPACE data02
2
3
DATAFILE 'D:\ORACLASS\ORADATA\u03\data02.dbf' SIZE 1M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 100K;
Tablespace created.
c.INDEX01 administrado localmente conextents de tamao uniforme de40K. Habilite extensin automtica de 500 KB cuando requiera ms extents con untamao mximo de MB.
SQL>CREATE TABLESPACE index01
2
3
4
DATAFILE 'D:\oraclass\ORADATA\u02\index01.dbf' SIZE 1M
AUTOEXTEND ON NEXT 500K MAXSIZE 2M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 40K;
Tablespace created.
d.RONLYpara tablas de solo lectura con almacenamiento por defecto. NO HAGA eltablespace en solo lectura para este momento.
SQL>CREATE TABLESPACE ronly
2 DATAFILE 'D:\ORACLASS\ORADATA\u01\ronly01.dbf' SIZE 1M;
Tablespace created.
.
-
7/26/2019 Administrando Tablespaces and datafiles
2/10
Administrando Tablespaces y Datafiles
e.Muestre la informacin desde el diccionario de datos.
Sugerencia:Informacin acerca de tablespaces pueden ser mostrados usando cualquiera de
las siguientes vistas.
- DBA_TABLESPACES
- V$TABLESPACE
- V$DATAFILE
SQL>SELECT tablespace_name FROMdba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS
TEMPINDX
SAMPLE
QUERY_DATA
EXAMPLEUSERS
DATA01
DATA02
INDEX01
RONLY
13 rows selected.
-
7/26/2019 Administrando Tablespaces and datafiles
3/10
Administrando Tablespaces y Datafiles
2.Asigne 500K de espacio de disco adicional al tablespaceDATA02.Verifique el resultado.
SQL>ALTER DATABASE
2 DATAFILE 'D:\ORACLASS\ORADATA\u03\data02.dbf' RESIZE 1500K;
Database altered.
SQL>COLUMN name FORMAT a40
SQL>SELECT name, bytes, create_bytes
2
3
FROM
WHERE
v$datafile
name LIKE '%DATA02%;
NAME BYTES CREATE_BYTES
------------------------------------- ------- ------------D:\oraclass\ORADATA\u03\data02.dbf 1048576 1048576
-
7/26/2019 Administrando Tablespaces and datafiles
4/10
Administrando Tablespaces y Datafiles
3.Reubicar al tablespaceINDEX01a la carpetau06. Verifique la reubicacin y el
estado deINDEX01.
Sugerencia:
-
-
-
-
-
-
Tome el tablespaceINDEX01fuera de lnea.
UseV$DATAFILEpara verificar el estado.
Use el comando move de sistema operativo para mover el tablespace au06.
UseALTER TABLESPACEpara reubicar al tablespace.
Ponga el tablespaceINDEX01online.
UseV$DATAFILEpara verificar el estado.
SQL>ALTER TABLESPACE index01 OFFLINE;
Tablespace altered.
SQL>SELECT name, status2 FROM v$datafile;
NAME STATUS
-------------------------------------------------- -------
D:\ORACLASS\ORADATA\u01\system01.dbf
D:\ORACLASS\ORADATA\u02\undotbs01.dbf
D:\ORACLASS\ORADATA\u03\users01.dbf
D:\ORACLASS\ORADATA\u03\indx01.dbf
D:\ORACLASS\ORADATA\u02\sample01.dbf
D:\ORACLASS\ORADATA\u01\querydata01.dbf
D:\ORACLASS\ORADATA\u04\data01.dbf
D:\ORACLASS\ORADATA\u03\data02.dbf
D:\ORACLASS\ORADATA\u02\index01.dbf
D:\ORACLASS\ORADATA\u01\ronly01.dbf
13 rows selected.
SQL>host move D:\ORACLASS\ORADATA\u02\index01.dbf
D:\ORACLASS\ORADATA\u06\index01.dbf
SQL>ALTER TABLESPACE index01
SYSTEM
ONLINE
ONLINE
ONLINE
ONLINE
ONLINE
ONLINE
ONLINE
OFFLINE
ONLINE
2
3
4
RENAME DATAFILE
'D:\ORACLASS\ORADATA\u02\index01.dbf' TO
'D:\ORACLASS\ORADATA\u06\index01.dbf';
Tablespace altered.
SQL>ALTER TABLESPACE index01 ONLINE;
Tablespace altered.
- continua -
-
7/26/2019 Administrando Tablespaces and datafiles
5/10
Administrando Tablespaces y Datafiles
- continua -
SQL>SELECT name, status
2FROM v$datafile;
NAME STATUS
-------------------------------------------------- -------
D:\ORACLASS\ORADATA\u01\system01.dbf
D:\ORACLASS\ORADATA\u01\sysaux01.dbf
D:\ORACLASS\ORADATA\u02\undotbs01.dbf
D:\ORACLASS\ORADATA\u03\users01.dbf
D:\ORACLASS\ORADATA\u03\indx01.dbf
D:\ORACLASS\ORADATA\u02\sample01.dbfD:\ORACLASS\ORADATA\u02\example01.dbf
D:\ORACLASS\ORADATA\u01\querydata01.dbf
D:\ORACLASS\ORADATA\u04\data01.dbf
D:\ORACLASS\ORADATA\u03\data02.dbf
D:\ORACLASS\ORADATA\u06\index01.dbf
D:\ORACLASS\ORADATA\u01\ronly01.dbf
D:\ORACLASS\ORADATA\u03\users01.dbf
13 rows selected.
SYSTEM
SYSTEM
ONLINE
ONLINE
ONLINE
ONLINEONLINE
ONLINE
ONLINE
ONLINE
ONLINE
ONLINE
ONLINE
-
7/26/2019 Administrando Tablespaces and datafiles
6/10
Administrando Tablespaces y Datafiles
4 . a.Crear una tabla en el tablespaceRONLY. Haga el tablespaceRONLYde solo lectura.
Ejecute la consulta para verificar esto.
SQL>CREATE TABLE table1 (x CHAR (1))
2TABLESPACE ronly;Table created.
SQL>ALTER TABLESPACE ronly READ ONLY;
Tablespace altered.
SQL>SELECT name, enabled, status
2FROM v$datafile;
NAME ENABLED STATUS
------------------------------------------- ---------- ------
D:\ORACLASS\ORADATA\u01\system01.dbf
D:\ORACLASS\ORADATA\u01\sysaux01.dbfD:\ORACLASS\ORADATA\u02\undotbs01.dbf
D:\ORACLASS\ORADATA\u03\users01.dbf
D:\ORACLASS\ORADATA\u03\indx01.dbf
D:\ORACLASS\ORADATA\u02\example01.dbf
D:\ORACLASS\ORADATA\u02\sample01.dbf
READ WRITE SYSTEM
READ WRITE SYSTEMREAD WRITE ONLINE
READ WRITE ONLINE
READ WRITE ONLINE
READ WRITE ONLINE
READ WRITE ONLINE
D:\ORACLASS\ORADATA\u01\querydata01.dbf READ ONLY ONLINE
D:\ORACLASS\ORADATA\u04\data01.dbfD:\ORACLASS\ORADATA\u03\data02.dbf
D:\ORACLASS\ORADATA\u06\index01.dbf
READ WRITE ONLINEREAD WRITE ONLINE
READ WRITE ONLINE
D:\ORACLASS\ORADATA\u01\ronly01.dbf READ ONLY ONLINE
D:\ORACLASS\ORADATA\u03\users01.dbf
13 rows selected.
READ WRITE ONLINE
-
7/26/2019 Administrando Tablespaces and datafiles
7/10
Administrando Tablespaces y Datafiles
4 . b.Intente crear una tabla adicionalTABLE2. Elimine la primera tabla creada,TABLE1.Que pasa?
SQL>CREATE TABLE table2 (y CHAR (1))
2 TABLESPACE ronly;
CREATE TABLE table2 (y CHAR (1))
*
ERROR at line 1:
ORA-01647: tablespace 'RONLY' is read only, cannot allocatespace in it
SQL>DROP TABLE table1;
Table dropped.
-
7/26/2019 Administrando Tablespaces and datafiles
8/10
Administrando Tablespaces y Datafiles
5Eliminar el tablespaceRONLYy el datafile asociado. Verificar lo realizado.
SQL>DROP TABLESPACE ronly INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
SQL>SELECT *
2 FROM v$tablespace;
TS# NAME INC
------- ------------- ---
0 SYSTEM
1 UNDOTBS
3 USERS
4 INDX
5 SAMPLE
2 TEMP
6 QUERY_DATA
7 DATA01
8 DATA02
9 INDEX01
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
10 rows selected.
SQL>host dir D:\ORACLASS\ORADATA\u01\*D:\ORACLASS\ORADATA\u01\control01.bak
D:\ORACLASS\ORADATA\u01\querydata01.dbf
D:\ORACLASS\ORADATA\u01\control01.ctl
D:\ORACLASS\ORADATA\u01\system01.dbf
-
7/26/2019 Administrando Tablespaces and datafiles
9/10
Administrando Tablespaces y Datafiles
6.ConfigurarDB_CREATE_FILE_DESTaD:\ORACLASS\ORADATA\u05solo en memoria.Crear el tablespaceDATA03de tamao 5M. No especifique la ubicacin del archivo.Verifique la creacin del archive de datos.
SQL>ALTER SYSTEM SETDB_CREATE_FILE_DEST='D:\ORACLASS\ORADATA\u05SCOPE=MEMORY;
System altered.
SQL>CREATE TABLESPACE data03
2 DATAFILE SIZE 5M;
Tablespace created.
SQL>SELECT *
2 FROM v$tablespace;
TS# NAME INC
------- ------------- ---
0 SYSTEM
1 UNDOTBS
3 USERS
4 INDX
5 SAMPLE
2 TEMP
6 QUERY_DATA
7 DATA018 DATA02
9 INDEX01
11 DATA03
YES
YES
YES
YES
YES
YES
YES
YESYES
YES
YES
-
7/26/2019 Administrando Tablespaces and datafiles
10/10
11 rows selected.
SQL>host dir D:\ORACLASS\ORADATA\u05
ora_data03_xg17n9nd.dbf