• TechOps

    Need clarity?
    Chat with our experts now

    • Web Hosting SupportWeb Hosting Support
    • Helpdesk Support

      Skilled and professional 24/7 helpdesk support

    • Product Support

      Boost your product support with our expertise

    • Managed ServicesManaged Services
    • Server Management

      Don't let server issues slow you down. Let us manage them for you

    • Server Monitoring

      Safeguard your server health with our comprehensive monitoring solutions

    • Staff AugmentationStaff Augmentation
    • Hire an Admin

      Transform your business operations with our expert administrative support

    • Hire a Team

      Augment your workforce with highly skilled professional from our diverse talent pool

  • CloudOps

    Confused?
    Discuss with our sales team now.

    • Author ProfileAWS
      Well Architected Review
    • Author ProfileFinOps As a Service

      FinOps As a Service

    • Migrate

      Upgrade the journey: Migrate & Modernize seamlessly

    • Modernize

      Effortless CloudOps mastery for seamless cloud management

    • Optimize

      Efficient CloudOps: Boosting performance through optimization

    • Manage

      Simplify compliance complexities with our dedicated service

  • DevOps

    How Supportsages
    is creating an
    impact?

    View Casestudies
    • Author Profile24/7 DevOps As a Service

      Round-the-clock DevOps for uninterrupted efficiency

    • Author ProfileCI/CD Pipeline

      Automated CI/CD pipeline for seamless deployments

    • Author ProfileInfrastructure As a Code

      Crafting infrastructure with ingenious code

    • Author ProfileDevSecOps

      Integrated security in continuous DevOps practices

    • Author ProfileHire DevOps Engineers

      Level up your team with DevOps visionaries

    • Author ProfileConsulting Services

      Navigate success with expert DevOps consulting

  • SecOps

    Expert SecOps Services
    for any Scale

    • Author ProfileVAPT

      Vulnerability Assessment and Penetration Testing

    • Author ProfileSource Code Review

      Ensuring source code security and safe practices to reduce risks

    • Author ProfileSecurity Consultation

      On demand services for improving server security

    • Author ProfileSystem Hardening

      Reduced vulnerability and proactive protection

    • Author ProfileManaged SOC

      Monitors and maintains system security. Quick response on incidents

    • Author ProfileCompliance as a Service

      Regulatory compliance, reduced risk

  • Insights

    Explore our latest
    insights and resources

    Blog

    Explore our latest articles and insights

    Case Studies

    Read about our client success stories

  • Contact Us

  • About
  • Certifications
  • Life at Supportsages
  • Events
  • Contact
  • Careers
  • Blog

  • Dedicated Support Team
  • Quasi-dedicated Support Team
  • Hire a DevOps Engineer
  • Hire a Billing Support Staff
  • Per-ticket Support Plan
  • Managed Services

  • Microsoft Azure Expert
  • AWS Cloud Expert
  • Hire a developer
SS

SupportSages

Bites of wisdom @ work


Copyright © 2008 - 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

How to copy all objects of one schema to other schema with in same PostgreSQL database?

Vinayan C V
  • 2 min read
How to copy all objects of one schema to other schema with in same PostgreSQL database?

Generating audio, please wait...

You can follow the following steps to copy all objects of one schema to another schema within the same PostgreSQL database:

1.Login to PostgreSQL using the following command

psql -h <host> -U <username> -d <databasename> -p <port no.>

2.Create the new schema using the following command

CREATE SCHEMA <new-schema-name>;

3.Check the relations of the source schema using the following command:

\dt <source-schema-name>.*

4.Rename the target schema to a different name and then rename the source schema to the target schema name. You can use the following commands:

ALTER SCHEMA <target-schema-name> RENAME TO <different-schema-name>;
ALTER SCHEMA <source-schema-name> RENAME TO <target-schema-name>;

5.Now log out from the PostgreSQL command line and take the dump of source schema which is renamed to target schema now. The following command can be used:

pg_dump -h <host> -U <username> -p <port> -n <target-schema-name> -d <databasename> >> <dump filename>
OR
pg_dump -U <username> -h <host> –schema=<target-schema-name> -d <databasename> -f <dump filename.backup>

6.Now login into PostgreSQL again and rename the source schema and target schema to their previous names.

ALTER SCHEMA <target-schema-name> RENAME TO <source-schema-name>;
ALTER SCHEMA <different-schema-name> RENAME TO <target-schema-name>;

7.Restore the database by using the below command

<blockquote>psql -U <username> -h <host> -d <databasename> -f <dump filename.backup</blockquote>

8.You can verify the same after login to PostgreSQL and running the following commands:

\dt <source-schema-name>.*

\dt <target-schema-name>.*

CONTACT US WITH YOUR REQUIREMENTS!!

  • PostgreSQL

Looking for AWS Experts?

We provide top-of-the-line custom AWS setup services tailored to your needs.

Amazon ECS Exec to access your containers on AWS Fargate Skip to end of metadata

Amazon ECS Exec to access your containers on AWS Fargate Skip to end of metadata
  • AWS
logo

Amazon SES Suppression List

Amazon SES Suppression List
  • AWS
logo

Azure VmScaleset Alert Configuration

Azure VmScaleset Alert Configuration
  • Linux
logo

EC2 Status check and restart using SSM runbook

EC2 Status check and restart using SSM runbook
  • Linux
logo
How to copy all objects of one schema to other schema with in same PostgreSQL database?
Posts by Vinayan C V

Vinayan C V