I have to write a program that detects corrupted tables and tries to repair them. For this I need to corrupt tables regularly.
Is there anyway to corrupt tables manually?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
Paul Randal has several Sample corrupt databases to play with:
DemoDataPurity - 192-MB SQL Server 2005 database with a single 2570 (data purity) error
DemoFatalCorruption1 - 1-MB SQL Server 2005 database with a corrupt system table (that allows CHECKDB to complete)
DemoFatalCorruption2 - 1-MB SQL Server 2005 database with a corrupt system table (that terminates CHECKDB)
DemoNCIndex - 192-MB SQL Server 2005 database with a bunch of nonclustered index corruptions
DemoRestoreOrRepair - 1-MB SQL Server 2005 database with a page checksum failure (in fact a zero'd out page)
DemoCorruptMetadata - 1-MB SQL Server 2000 database with corrupt syscolumns table
I don't actually know what makes a table corrupt, but since you'll be scanning for certain symptoms, you know that, right? So you could just open the database file in, say, a hex editor and modify the corresponding data, e.g. change a value representing the number of records to come or something like that?