ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Need to Extract PostgreSQL Schema for Clean Database

    IT Discussion
    database postgresql sql
    3
    5
    1.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • StrongBadS
      StrongBad
      last edited by

      I'm not an expert on PostgreSQL but I need to do some trouble shooting with an instance of it and am stuck as to how to proceed. What I am trying to do is to take one existing database instance and create a clone of it that is empty that I can then do testing with. I want to avoid altering the original database for obvious reasons.

      Here is what I have currently:

      postgres=# \l
              List of databases
          Name    |  Owner   | Encoding 
      ------------+----------+----------
       portal_old | phppg    | LATIN9
       portaltest | phppg    | LATIN9
       postgres   | postgres | LATIN9
       template0  | postgres | LATIN9
       template1  | postgres | LATIN9
      (5 rows)
      

      The database that needs to be copied is portaltest. Unfortunately there is not enough space on the server to make a full copy of the database itself (legacy problems) which adds additional complications.

      So I cannot take a full pg_dump of the database. If I try to use the -n flag of pg_dump to only get the schema it tells me that no schema can be found.

      I am unclear how to pull out the framework of the database to make a copy given the scenario.

      1 Reply Last reply Reply Quote 1
      • scottalanmillerS
        scottalanmiller
        last edited by

        What is the error produced by the schema dump?

        1 Reply Last reply Reply Quote 0
        • StrongBadS
          StrongBad
          last edited by

          This is what I get...

          postgres@~ 2$ pg_dump -p 5023 -n portaltest
          pg_dump: specified schema "portaltest" does not exist
          
          MattSpellerM 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller
            last edited by

            No idea on that.

            1 Reply Last reply Reply Quote 0
            • MattSpellerM
              MattSpeller @StrongBad
              last edited by

              @StrongBad said in Need to Extract PostgreSQL Schema for Clean Database:

              This is what I get...

              postgres@~ 2$ pg_dump -p 5023 -n portaltest
              pg_dump: specified schema "portaltest" does not exist
              

              http://orig01.deviantart.net/eb26/f/2011/145/e/2/portal_2___error_by_half_dude-d3h8bys.jpg

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post