Précédent   Forum des professionnels en informatique > Bases de données > Oracle > Import/Export
Import/Export Forum d'entraide sur les outils d'import/export Oracle
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 13/06/2007, 18h00   #1
Membre à l'essai
 
Inscription : juillet 2002
Messages : 403
Détails du profil
Informations forums :
Inscription : juillet 2002
Messages : 403
Points : 20
Points : 20
Par défaut Renommer un tablespace

Bonjour;


J'essaye de renommer une tablespace mais apparemment on ne peux le faire qu'à partir de la version 10g (je suis en version 9.2).

Donc pour contourné le pb de je vais Crée un nouveau tablespace identique au tablespace courant, ensuite si tout va bien, je détruit l'ancien tablespace » par la commande drop tablespace ….

Est ce une bonne solution et comment j'écris l'instruction de création d'une tablesapce à partir de celle quiexiste déjà.


Merci;
yanis97 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/06/2007, 18h41   #2
Membre du Club
 
Inscription : décembre 2005
Messages : 76
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 76
Points : 42
Points : 42
Oh oui, cette option n’existe pas en 9i
De ce fait il faut procédé ainsi :

-Export de tous les objets du tablespace
-Drop le tablespace avec son contenu
-Création du nouveau tablespace
-Import des objets.
sofiane1111 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/06/2007, 22h43   #3
Rédacteur/Modérateur
 
Avatar de orafrance
 
Inscription : janvier 2004
Messages : 15 861
Détails du profil
Informations personnelles :
Âge : 35

Informations forums :
Inscription : janvier 2004
Messages : 15 861
Points : 16 212
Points : 16 212
ou plus simplement :
- création du tablespace avec le nom correct
- MOVE ou REBUILD pour déplacer les objets
- drop de tablespace vidé
orafrance est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/06/2007, 11h15   #4
Membre chevronné
 
Avatar de 13thFloor
 
Homme
DBA Oracle freelance
Inscription : janvier 2005
Messages : 558
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 45
Localisation : France

Informations professionnelles :
Activité : DBA Oracle freelance

Informations forums :
Inscription : janvier 2005
Messages : 558
Points : 718
Points : 718
Citation:
Envoyé par yanis97
...comment j'écris l'instruction de création d'une tablesapce à partir de celle quiexiste déjà.
Merci;
L'utilisation du package dbms_metadata devrait t'aider à récupérer le code SQL de ton tablesapce. Il faudra que tu modifies le résultat pour incorporer les caractéristiques du nouveau TS :
Code :
1
2
SET long 20000
SELECT dbms_metadata.get_ddl('TABLESPACE','nom_de_TS') FROM dual;
13thFloor est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2007, 14h26   #5
Nouveau Membre du Club
 
Inscription : juin 2007
Messages : 52
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : juin 2007
Messages : 52
Points : 37
Points : 37
L'export / Import de fonctionne pas.

Le nom du schéma ne change pas. Lors de l'import Oracle dis que les objets existent deja !!!

Exemple :
Creation nouveau TBS
Code :
1
2
3
4
5
6
7
SQL> SELECT dbms_metadata.get_ddl('TABLESPACE','GL') FROM dual;
 
DBMS_METADATA.GET_DDL('TABLESPACE','GL')
--------------------------------------------------------------------------------
 
  CREATE TABLESPACE "GL" DATAFILE
  '/u02/oradata/ateqora/gl01.dbf' SIZE 33554
Code :
1
2
3
4
 
SQL> CREATE TABLESPACE GL_TEMP DATAFILE'/u02/oradata/ateqora/gl_temp01.dbf' SIZE 32M ;
 
Tablespace created
Export dans le nouveau TBS
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
oracle@ateq-gl ateqora]$ exp userid=system/manager file=/u02/oradata/ateqora/dump/gl_tbs.dmp log=/u02/oradata/ateqora/dump/gl_tbs.log tablespaces=gl
 
Export: Release 10.2.0.1.0 - Production ON Wed Jun 20 13:55:35 2007
 
Copyright (c) 1982, 2005, Oracle.  ALL rights reserved.
 
 
Connected TO: Oracle DATABASE 10g Enterprise Edition Release 10.2.0.1.0 - Production
WITH the Partitioning, OLAP AND DATA Mining options
Export done IN US7ASCII character SET AND AL16UTF16 NCHAR character SET
server uses AL32UTF8 character SET (possible charset conversion)
 
About TO export selected tablespaces ...
FOR tablespace GL ...
. exporting cluster definitions
. exporting TABLE definitions
. . exporting TABLE                      PERSONNES          3 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
. . exporting TABLE                           TEST          8 rows exported
EXP-00091: Exporting questionable statistics.
. . exporting TABLE                       VOITURES          3 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
. exporting referential integrity constraints
. exporting triggers
Export terminated successfully WITH warnings.
Import dans le nouveau TBS ==> ERREUR
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
oracle@ateq-gl ateqora]$ imp userid=system/manager file=/u02/oradata/ateqora/dump/gl_tbs.dmp log=/u02/oradata/ateqora/dump/imp_gl_tbs.log tablespaces=gl_temp full=y
 
Import: Release 10.2.0.1.0 - Production ON Wed Jun 20 13:56:49 2007
 
Copyright (c) 1982, 2005, Oracle.  ALL rights reserved.
 
 
Connected TO: Oracle DATABASE 10g Enterprise Edition Release 10.2.0.1.0 - Production
WITH the Partitioning, OLAP AND DATA Mining options
 
Export file created BY EXPORT:V10.02.01 via conventional path
import done IN US7ASCII character SET AND AL16UTF16 NCHAR character SET
import server uses AL32UTF8 character SET (possible charset conversion)
. importing SYSTEM's objects into SYSTEM
. importing GL's objects INTO GL
IMP-00015: following statement failed because the object already EXISTS:
 "CREATE TABLE "PERSONNES" ("PERS_ID" VARCHAR2(5), "PERS_NOM" VARCHAR2(10), ""
 "PERS_PRENOM" VARCHAR2(15), "VOIT_ID" VARCHAR2(5))  PCTFREE 10 PCTUSED 40 IN"
 "ITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1 B"
 "UFFER_POOL DEFAULT)                 LOGGING NOCOMPRESS"
IMP-00015: following statement failed because the object already EXISTS:
 "CREATE TABLE "TEST" ("ID" NUMBER(2, 0), "TEXTE" VARCHAR2(10))  PCTFREE 10 P"
 "CTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIS"
 "T GROUPS 1 BUFFER_POOL DEFAULT)                 LOGGING NOCOMPRESS"
IMP-00015: following statement failed because the object already EXISTS:
 "CREATE TABLE "VOITURES" ("VOIT_ID" VARCHAR2(5), "MARQUE" VARCHAR2(10), "TYP"
 "E" VARCHAR2(15), "PUISSANCE" NUMBER(3, 0))  PCTFREE 10 PCTUSED 40 INITRANS "
 "1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1 BUFFER_P"
 "OOL DEFAULT)                 LOGGING NOCOMPRESS"
Import terminated successfully WITH warnings.
En effet tout les objects existent deja dans le schéma. Il faut passer par un utilisateur alternatif ... Et ceci meme apres :

Code :
1
2
 
ALTER USER GL DEFAULT TABLESPACE GL_TEMP ;
lapincretin est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2007, 14h56   #6
Nouveau Membre du Club
 
Inscription : juin 2007
Messages : 52
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : juin 2007
Messages : 52
Points : 37
Points : 37
La manip' que j'ai fais rapidement :

Puisque l'import se fie aux objets présents du schéma voici comment procéder :

Avec ce code, recuperer les schémas qui sont inscrit dans le tablespace a migrer :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
Export terminated successfully without warnings.
[oracle@ateq-gl ateqora]$ exp userid=system/manager file=/u02/oradata/ateqora/dump/gl_tbs.dmp log=/u02/oradata/ateqora/dump/gl_tbs.log owner=gl;
 
Export: Release 10.2.0.1.0 - Production ON Wed Jun 20 14:25:40 2007
 
Copyright (c) 1982, 2005, Oracle.  ALL rights reserved.
 
 
Connected TO: Oracle DATABASE 10g Enterprise Edition Release 10.2.0.1.0 - Production
WITH the Partitioning, OLAP AND DATA Mining options
Export done IN US7ASCII character SET AND AL16UTF16 NCHAR character SET
server uses AL32UTF8 character SET (possible charset conversion)
 
About TO export specified users ...
. exporting pre-schema PROCEDURAL objects AND actions
. exporting FOREIGN FUNCTION library names FOR user GL
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions FOR user GL
About TO export GL's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export GL's TABLES via Conventional Path ...
. . exporting TABLE                      PERSONNES          3 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
. . exporting TABLE                   SYS_TEMP_FBT
. . exporting TABLE                           TEST         24 rows exported
EXP-00091: Exporting questionable statistics.
. . exporting TABLE                       VOITURES          3 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional AND extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups AND children
. exporting dimensions
. exporting post-schema PROCEDURAL objects AND actions
. exporting statistics
Export terminated successfully WITH warnings.
Supprimer le schéma GL ainsi que les objets, et recréer un schéma du meme nom vide :
Code :
1
2
3
4
5
6
7
8
 
SQL> DROP user gl cascade;
 
User dropped.
 
SQL> CREATE user gl IDENTIFIED BY gl DEFAULT tablespace gl_temp;
 
User created.
Donner au nouveau utilisateur GL le droit d'écriture sur le nouveau tablespace
Code :
1
2
3
4
 
SQL> ALTER user gl quota unlimited ON gl_temp;
 
User altered.
Faire l'import
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
[oracle@ateq-gl ateqora]$ imp userid=system/manager file=/u02/oradata/ateqora/dump/gl_tbs.dmp log=/u02/oradata/ateqora/dump/imp_gl_tbs.log full=y
 
Import: Release 10.2.0.1.0 - Production ON Wed Jun 20 14:28:38 2007
 
Copyright (c) 1982, 2005, Oracle.  ALL rights reserved.
 
 
Connected TO: Oracle DATABASE 10g Enterprise Edition Release 10.2.0.1.0 - Production
WITH the Partitioning, OLAP AND DATA Mining options
 
Export file created BY EXPORT:V10.02.01 via conventional path
import done IN US7ASCII character SET AND AL16UTF16 NCHAR character SET
import server uses AL32UTF8 character SET (possible charset conversion)
. importing SYSTEM's objects into SYSTEM
. importing GL's objects INTO GL
. . importing TABLE                    "PERSONNES"          3 rows imported
. . importing TABLE                         "TEST"         24 rows imported
. . importing TABLE                     "VOITURES"          3 rows imported
About TO enable constraints...
Import terminated successfully without warnings.
Vérifier les objets dans l'anciens et le nouveau tablespace
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
SQL*Plus: Release 10.2.0.1.0 - Production ON Wed Jun 20 14:28:57 2007
 
Copyright (c) 1982, 2005, Oracle.  ALL rights reserved.
 
 
Connected TO:
Oracle DATABASE 10g Enterprise Edition Release 10.2.0.1.0 - Production
WITH the Partitioning, OLAP AND DATA Mining options
 
SQL> SELECT count(*) FROM dba_segments WHERE tablespace_name = 'GL';
 
  COUNT(*)
----------
         0
 
SQL> SELECT count(*) FROM dba_segments WHERE tablespace_name = 'GL_TEMP';
 
  COUNT(*)
----------
         5
Suppression de l'ancien tablespace si il n'y a plus d'objets
Code :
1
2
3
4
 
SQL> DROP tablespace GL including contents AND datafiles;
 
Tablespace dropped.
Voila ...
Ce n'est peut etre pas parfait, mais j'ai fais ca entre 2

PS Dans ma démo, GL est un user, GL est le tablespace 'source', GL_TEMP est la tablespace 'cible'.
lapincretin est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2007, 15h09   #7
Rédacteur/Modérateur
 
Avatar de orafrance
 
Inscription : janvier 2004
Messages : 15 861
Détails du profil
Informations personnelles :
Âge : 35

Informations forums :
Inscription : janvier 2004
Messages : 15 861
Points : 16 212
Points : 16 212
t'as pas besoin de recréer le user, l'import s'en charge
orafrance est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2007, 20h53   #8
Membre habitué
 
Inscription : juin 2006
Messages : 170
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 170
Points : 143
Points : 143
Citation:
Envoyé par orafrance
ou plus simplement :
- création du tablespace avec le nom correct
- MOVE ou REBUILD pour déplacer les objets
- drop de tablespace vidé
par contre si une table possède un champs de type LONG faudra passer par l'export/import
couak est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h33.


 
 
 
 
Partenaires

Hébergement Web