dump schema schema only?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick Hatcher

    dump schema schema only?

    I have a development server where I, well, do my development. Occasionally,
    I will create a new schema within an existing database that I would like to
    use on my production machine. I know that doing a pg_dump -s <database>[color=blue]
    > somefile.sql will dump the entire schema of the database, but is there a[/color]
    way to export only schema X from the database?

    TIA
    Patrick Hatcher



    ---------------------------(end of broadcast)---------------------------
    TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddres sHere" to majordomo@postg resql.org)

  • Rick Seeger

    #2
    Re: dump schema schema only?


    You can use -t to specify a table:

    % pg_dump -s database -t tablename


    -Rick



    -----Original Message-----
    From: pgsql-general-owner@postgresq l.org
    [mailto:pgsql-general-owner@postgresq l.org]On Behalf Of Patrick
    Hatcher
    Sent: Wednesday, October 29, 2003 12:57 PM
    To: pgsql-general@postgre sql.org
    Subject: [GENERAL] dump schema schema only?


    I have a development server where I, well, do my development.
    Occasionally,
    I will create a new schema within an existing database that I would
    like to
    use on my production machine. I know that doing a pg_dump -s
    <database>[color=blue]
    > somefile.sql will dump the entire schema of the database, but is[/color]
    there a
    way to export only schema X from the database?

    TIA
    Patrick Hatcher



    ---------------------------(end of
    broadcast)---------------------------
    TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddres sHere" to
    majordomo@postg resql.org)




    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain analyze is your friend

    Comment

    • Tom Lane

      #3
      Re: dump schema schema only?

      "Patrick Hatcher" <PHatcher@macys .com> writes:[color=blue]
      > I have a development server where I, well, do my development. Occasionally,
      > I will create a new schema within an existing database that I would like to
      > use on my production machine. I know that doing a pg_dump -s <database>[color=green]
      > > somefile.sql will dump the entire schema of the database, but is there a[/color]
      > way to export only schema X from the database?[/color]

      7.4's pg_dump has an option to dump the contents of just one schema.

      regards, tom lane

      ---------------------------(end of broadcast)---------------------------
      TIP 8: explain analyze is your friend

      Comment

      • Harald Fuchs

        #4
        Re: dump schema schema only?

        In article <20051.10674599 01@sss.pgh.pa.u s>,
        Tom Lane <tgl@sss.pgh.pa .us> writes:
        [color=blue]
        > "Patrick Hatcher" <PHatcher@macys .com> writes:[color=green]
        >> I have a development server where I, well, do my development. Occasionally,
        >> I will create a new schema within an existing database that I would like to
        >> use on my production machine. I know that doing a pg_dump -s <database>[color=darkred]
        >> > somefile.sql will dump the entire schema of the database, but is there a[/color]
        >> way to export only schema X from the database?[/color][/color]
        [color=blue]
        > 7.4's pg_dump has an option to dump the contents of just one schema.[/color]

        The pg_dump manpage of beta4 does not include this option, although
        the source code does. Has this been fixed in beta5?


        ---------------------------(end of broadcast)---------------------------
        TIP 6: Have you searched our list archives?



        Comment

        • Tom Lane

          #5
          Re: dump schema schema only?

          Harald Fuchs <nospam@sap.com > writes:[color=blue]
          > Tom Lane <tgl@sss.pgh.pa .us> writes:[color=green]
          >> 7.4's pg_dump has an option to dump the contents of just one schema.[/color][/color]
          [color=blue]
          > The pg_dump manpage of beta4 does not include this option,[/color]

          Sure it does:

          -n namespace
          --schema=schema

          Dump the contents of schema only. If this option is not specified,
          all non-system schemas in the target database will be dumped.

          regards, tom lane

          ---------------------------(end of broadcast)---------------------------
          TIP 5: Have you checked our extensive FAQ?



          Comment

          • Bruce Momjian

            #6
            Re: dump schema schema only?

            Harald Fuchs wrote:[color=blue]
            > In article <20051.10674599 01@sss.pgh.pa.u s>,
            > Tom Lane <tgl@sss.pgh.pa .us> writes:
            >[color=green]
            > > "Patrick Hatcher" <PHatcher@macys .com> writes:[color=darkred]
            > >> I have a development server where I, well, do my development. Occasionally,
            > >> I will create a new schema within an existing database that I would like to
            > >> use on my production machine. I know that doing a pg_dump -s <database>
            > >> > somefile.sql will dump the entire schema of the database, but is there a
            > >> way to export only schema X from the database?[/color][/color]
            >[color=green]
            > > 7.4's pg_dump has an option to dump the contents of just one schema.[/color]
            >
            > The pg_dump manpage of beta4 does not include this option, although
            > the source code does. Has this been fixed in beta5?[/color]

            Really? Perhaps we haven't updated the manual pages, but the SGML is
            OK. I have added this to the list to be done before 7.4 final.

            --
            Bruce Momjian | http://candle.pha.pa.us
            pgman@candle.ph a.pa.us | (610) 359-1001
            + If your life is a hard drive, | 13 Roberts Road
            + Christ can be your backup. | Newtown Square, Pennsylvania 19073

            ---------------------------(end of broadcast)---------------------------
            TIP 7: don't forget to increase your free space map settings

            Comment

            • Bruce Momjian

              #7
              Re: dump schema schema only?

              Tom Lane wrote:[color=blue]
              > Harald Fuchs <nospam@sap.com > writes:[color=green]
              > > Tom Lane <tgl@sss.pgh.pa .us> writes:[color=darkred]
              > >> 7.4's pg_dump has an option to dump the contents of just one schema.[/color][/color]
              >[color=green]
              > > The pg_dump manpage of beta4 does not include this option,[/color]
              >
              > Sure it does:
              >
              > -n namespace
              > --schema=schema
              >
              > Dump the contents of schema only. If this option is not specified,
              > all non-system schemas in the target database will be dumped.[/color]

              I thought he was complaining because our 'man' output wasn't updated for
              7.4. I just checked beta5's man.tar.gz, and it has the 7.3 contents,
              and doesn't mention -n/--schema. I have added to our open items list:

              Update manual pages.

              --
              Bruce Momjian | http://candle.pha.pa.us
              pgman@candle.ph a.pa.us | (610) 359-1001
              + If your life is a hard drive, | 13 Roberts Road
              + Christ can be your backup. | Newtown Square, Pennsylvania 19073

              ---------------------------(end of broadcast)---------------------------
              TIP 6: Have you searched our list archives?



              Comment

              Working...