IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Import/Export Oracle Discussion :

Renommer un tablespace


Sujet :

Import/Export Oracle

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    428
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 428
    Points : 60
    Points
    60
    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;

  2. #2
    Membre du Club
    Inscrit en
    Décembre 2005
    Messages
    76
    Détails du profil
    Informations forums :
    Inscription : Décembre 2005
    Messages : 76
    Points : 67
    Points
    67
    Par défaut
    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.

  3. #3
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    ou plus simplement :
    - création du tablespace avec le nom correct
    - MOVE ou REBUILD pour déplacer les objets
    - drop de tablespace vidé

  4. #4
    Membre éprouvé Avatar de 13thFloor
    Homme Profil pro
    DBA Oracle freelance
    Inscrit en
    Janvier 2005
    Messages
    670
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France

    Informations professionnelles :
    Activité : DBA Oracle freelance

    Informations forums :
    Inscription : Janvier 2005
    Messages : 670
    Points : 945
    Points
    945
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    set long 20000
    select dbms_metadata.get_ddl('TABLESPACE','nom_de_TS') from dual;

  5. #5
    Membre du Club
    Inscrit en
    Juin 2007
    Messages
    52
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Juin 2007
    Messages : 52
    Points : 46
    Points
    46
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ALTER USER GL DEFAULT TABLESPACE GL_TEMP ;

  6. #6
    Membre du Club
    Inscrit en
    Juin 2007
    Messages
    52
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Juin 2007
    Messages : 52
    Points : 46
    Points
    46
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    SQL> alter user gl quota unlimited on gl_temp;
     
    User altered.
    Faire l'import
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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'.

  7. #7
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    t'as pas besoin de recréer le user, l'import s'en charge

  8. #8
    Membre habitué
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 175
    Points : 180
    Points
    180
    Par défaut
    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

Discussions similaires

  1. Renommer une Base
    Par YanK dans le forum Requêtes
    Réponses: 7
    Dernier message: 25/10/2017, 13h24
  2. Renommer une database Postgres
    Par Johnybegood dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 16/10/2014, 09h49
  3. unable to create INITIAL extent for segment in tablespace
    Par Ludolitaliano dans le forum Administration
    Réponses: 4
    Dernier message: 11/09/2003, 16h43
  4. [] [Réseau] Renommer des fichiers dans un site FTP
    Par JerBi dans le forum VB 6 et antérieur
    Réponses: 10
    Dernier message: 22/08/2003, 00h35
  5. Renommer un repertoire
    Par Sitas dans le forum Langage
    Réponses: 5
    Dernier message: 14/08/2002, 11h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo