By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

How to Fix Corrupt Tables

P: 13
Hi there, i'm busy with quite a large project using PostgreSQL. Now the problem is that one of our data tables seems to have been corrupted. I cant open the table certain SQL queries like select does return results but the returned results are selective meaning that only certain fields are returned and not every thing that you asked for.

Is there a way to fix this or would we need to recreate the table and reload it with the data from the begining.

PS: attempts to export the data in the table have failed thus far.

Thanx in advance

Johan Kestlmeier
Jan 31 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 534
You did not give enough information to understand what's going on with your db.
I would suggest to open psql session and run these queries:

1.\d -- display table listing
2 \d my_bad_table -- display the table defiunition
3. select count (*) from my_bad_table ;
4. vacuum;
5 vacuum analyze;
6. vacuum full;

If you have a problem at some point one of these commands would most likely result in an obvious error.
Copy and paste here all output.

Make sure that you created db backup before going through with this.
pg_dump may not work if you have corrupted db, stop database and create a recursive copy or tar-ball of your data directory.
Jan 31 '07 #2

Expert 100+
P: 534
If you intend to continue using database replace it with your backup after you encountered errors from the commands I suggested above.
Make sure you stop the server before you create a backup or put it back in place.
Jan 31 '07 #3

P: 13
Thanx for the help

Feb 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.