I want to drop a tablespace, but it says tablespace is not empty. What am I missing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leoris90
    New Member
    • May 2019
    • 1

    I want to drop a tablespace, but it says tablespace is not empty. What am I missing?

    Hello everyone,

    I moved all tables and indices out of a tablespace to a different tablespace (different hard drive and different mountpoint). Now I want to drop the old tablespace but it says the tablespace is not empty.

    If I go into the tablespace directory i see bunch of files. I was told that these cannot be deleted, but if I'm trying to drop this tablespace anyway, can I just delete these files? Will this affect the tables that are moved to the new tablespace

    Code:
    <code>PG_9.5_201510051/259388 # du -sh *
    1.1G    2935335227
    1.1G    2935335227.1
    1.1G    2935335227.2
    138M    2935335227.3
    1.1G    2935335230
    1.1G    2935335230.1
    1.1G    2935335230.2
    1.1G    2935335230.3
    1.1G    2935335230.4
    1.1G    2935335230.5
    266M    2935335230.6
    139M    2935335232</code>
    Any guidance would be appreciated
    Thanks in advance
    Last edited by zmbd; May 22 '19, 02:58 AM. Reason: [z{fixed code tags for thread use [] not <>}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    !! Very important, make absolutely sure you have a backup of your database. It's very difficult to recover !!

    Have you tried the following:

    Login to the database as the owner or superuser
    Code:
    DROP DATABASE dbYourDbNameHere;
    DROP TABLESPACE yourTableSpaceNameHere;

    Comment

    • Gevoergun
      New Member
      • Mar 2022
      • 1

      #3
      The tablespace files take up too little space for you to delete them for no good reason.

      Comment

      • Zentro
        New Member
        • Mar 2022
        • 1

        #4
        You can delete tablespace files. However, you cannot be completely sure that you are not deleting something important. I, too, thought these files were not that important and ended up deleting important system files that were worth keeping on disk. Of course, that was stupid. Don't repeat my mistakes if you don't want to go to salvagedata.com later. I turned to them because I knew that there was no other way to get back the important table space configurations that I had foolishly erased from my computer's memory irretrievably. Thankfully, there are now services like this, where they can save and restore everything.

        Comment

        Working...