PDA

View Full Version : Tablespace



Warbarbie
15th January 2010, 18:20
Qualcuno sa come e se si puo cambiare il nome di una TB via Unix senza rischiare di smerdare il db?

Ladro di anime
15th January 2010, 18:32
Si ma di cosa :sneer:, quale database e che versione?

Warbarbie
15th January 2010, 18:38
Oracle 9
Stavo(sto) nel panico e ho postato così

Ladro di anime
15th January 2010, 18:40
da quello che so si, arrivo a casa e ti dico.

Warbarbie
15th January 2010, 18:45
Ho provato con la procedura tramite TOAD, ma non mi fa mettere offline la tablespace per il cambio.
Randolk me l'ha sempre detto di non toccare un cazzo il venerdi sera pd

Ladro di anime
15th January 2010, 19:08
Mo ci guardo, ma cmq si fa tramite un comando sql, prima di fare qualsiasi cosa fatti un export del database che devi toccare.

Ladro di anime
15th January 2010, 19:11
Tablespace Rename Overview

In Oracle 10g, you can simply rename a tablespace TBS01 to TBS02 by issuing the following command:

ALTER TABLESPACE tbs01 RENAME TO tbs02;

However, you must follow the rules when renaming a tablespace:

You must set compatibility level to at least 10.0.1.
You cannot rename the SYSTEM or SYSAUX tablespaces.
You cannot rename an offline tablespace.
You cannot rename a tablespace that contains offline datafiles.
Renaming a tablespace does not changes its tablespace identifier.
Renaming a tablespace does not change the name of its datafiles.
Tablespace Rename Benefits

Tablespace rename provides the following benefits:

It simplifies the process of tablespace migration within a database.
It simplifies the process of transporting a tablespace between two databases.
Examples

Example 1: Rename a tablespace within a database. In Oracle9i or earlier releases, you must take the following steps to rename a tablespace from OLD_TBS to NEW_TBS:

Create a new tablespace NEW_TBS.
Copy all objects from OLD_TBS to NEW_TBS.
Drop tablespace OLD_TBS.
In Oracle 10g, you can accomplish the same thing in one step:

Rename tablespace OLD_TBS to NEW_TBS.
ALTER TABLESPACE RENAME old_tbs to new_tbs;

Example 2: Transport a tablespace between two databases. In the following example (see figure 3.2), you cannot transport a tablespace TBS01 from database A to database B in the previous release of Oracle server because database B also has a tablespace called TBS01. In Oracle 10g, you can simply rename TBS01 to TBS02 in database B before transporting tablespace TBS01.


In sintesi dovresti creartene uno nuovo e poi spostare tutto da uno all'altro.

Quello che ricordavo io è solo per la 10g

Ladro di anime
15th January 2010, 19:13
Altrimenti puoi passare con l'export/import

Oracle 9i:

SQL> CREATE TABLESPACE test1 DATAFILE ‘/u01/app/orsbox/proddata/test1.dbf’ size 500M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

Tablespace created.

For Renaming the tablespace, we don’t have a direct command in 9i. For that we need to follow the below steps.

1) Export all of the objects from the tablespace

[orsbox@ocvmrh2124 9.2.0]$ exp system/manager FILE=test1.dmp LOG=test1.log TABLESPACES=test1

Export: Release 9.2.0.3.0 – Production on Thu Jul 12 01:02:37 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to: Oracle9i Enterprise Edition Release 9.2.0.3.0 – Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.3.0 – Production
Export done in US7ASCII character set and AL16UTF16 NCHAR character set

About to export selected tablespaces …
For tablespace TEST1 …
. exporting cluster definitions
. exporting table definitions
. exporting referential integrity constraints
. exporting triggers
Export terminated successfully without warnings.

2) Drop the tablespace including contents

SQL> drop tablespace test1 including contents;

Tablespace dropped.

3) Recreate the tablespace

SQL> CREATE TABLESPACE test2 DATAFILE ‘/u01/app/orsbox/proddata/test1.dbf’ size 500M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

Tablespace created.

4) Import the objects

[orsbox@ocvmrh2124 9.2.0]$ imp system/manager FILE=test1.dmp LOG=test1.log FULL=Y TABLESPACES=test2

Import: Release 9.2.0.3.0 – Production on Thu Jul 12 01:27:47 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to: Oracle9i Enterprise Edition Release 9.2.0.3.0 – Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.3.0 – Production

Export file created by EXPORT:V09.02.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
. importing SYSTEM’s objects into SYSTEM
Import terminated successfully without warnings.
[orsbox@ocvmrh2124 9.2.0]$

Io sono sempre passato per l'utente, visto che andiamo con 1 tablespace -> 1 utente.

Per cui facevo l'export dell'utente e lo reimportavo in un altro utente che aveva di conseguenza un'altro tablespace di riferimento.

Tanek
15th January 2010, 19:21
Si ma se è un tablespace peso (con molti dati) ci metti una vita a fare import/export immagino..
(beh che se dici che hai sbagliato il nome mi sa che l'hai appena creato e quindi è vuoto :P )

ps: no, non devi toccare un cavolo il venerdì sera :)

San Vegeta
15th January 2010, 19:54
dalle 14 di venerdì non si fa niente di anche vagamente importante, ed è buona norma staccare il telefono in ufficio