2

This question already has an answer here:

All too often I see questions that are vague and just outright difficult to understand. I try to send the OPs to Stack Overflow's MCVE page, but that doesn't seem to work often enough and I wonder if we need to create a dba-flavored MCVE page on our help site.

I would envision something similar to SO's page, but modified with a DBA audience in mind. So maybe something similar to the following (and edits are more than welcome here):

Note: This page is derived from the MCVE help page found at https://stackoverflow.com/help/mcve

How to create a Minimal, Complete, and Verifiable example

When asking a question about a problem within your database solution, you will get much better answers if you provide data and code people can use to reproduce the problem. That data and code should be…

  • …Minimal – Use as little data and code as possible that still produces the same problem
  • …Complete – Provide all parts needed to reproduce the problem, including basic table structure, troublesome queries, and execution/explain plans
  • …Verifiable – Test the code you're about to provide to make sure it reproduces the problem

Minimal

The more code or data there is to go through, the less likely people can find your problem. Streamline your example in one of two ways:

  1. Restart from scratch. Create a new database model, adding only the data that is needed to see the problem. This can be faster for vast systems where you think you already know the source of the problem. Also useful if you can't post the original table structure/data publicly for legal or ethical reasons. You can even use an online resource such as db<>fiddle or SQL Fiddle both of which support most major RDBMS platforms.
  2. Divide and conquer. When you have a small amount of data or code, but the source of the problem is entirely unclear, start removing code a bit at a time until the problem disappears – then add the last part back. Not only can this help you identify the problem is with your code or with the data, but allows you to include that in your question for others to review.

Minimal and readable

Minimal does not mean terse – don't sacrifice communication to brevity. Use consistent naming and formatting, and include comments if needed to explain portions of the code or the table structures you're defining.

Complete

Make sure all information necessary to reproduce the problem is included:

  • Some people might be prepared to load the parts up, and actually try them to test the answer they're about to post. Again if this is even easier if you build your MCVE in either db<>fiddle or SQL Fiddle which allow others to run your solution.
  • The problem might not be in the part you suspect it is, but another part entirely.

If the problem requires external objects from a database, include them if possible or at least a description of what is needed.

Verifiable

To help you solve your problem, others will need to verify that it exists:

  • Describe the problem. "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Put a brief summary of the problem in the title of your question.
  • Eliminate any issues that aren't relevant to the problem. If your question isn’t about a syntax error, ensure that it can run without being modified.
  • Ensure that the example actually reproduces the problem! If you inadvertently fixed the problem while composing the example but didn't test it again, you'd want to know that before asking someone else to help.

You may have been told to include an MCVE by some helpful commentary, or perhaps even an MVCE if they were rushed; sorry for the initialisms, this is what they were referring to.

marked as duplicate by Max Vernon, Community Jul 25 '18 at 13:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged .