4

When asking questions, shouldn't we encourage new (indeed all) posters to give DDL and DML rather than table descriptions and rows of data?

I'll use a trivial example from MySQL.

mysql> create table fred(billy int, joe int, PRIMARY KEY (billy));
mysql> insert into fred values(1,1);
mysql> insert into fred values(2, 1);
mysql> insert into fred values(3, 1);

Now, we should encourage posters NOT to post the following as their table defintion:

mysql> desc fred;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| billy | int(11) | NO   | PRI | 0       |       |
| joe   | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+

But rather:

mysql> show create table fred; <some stuff deleted...>
CREATE TABLE `fred` (
  `billy` int(11) NOT NULL DEFAULT '0',
  `joe` int(11) DEFAULT NULL,
  PRIMARY KEY (`billy`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; 

And likewise, data should NOT be given as:

mysql> select * from fred;
+-------+------+
| billy | joe  |
+-------+------+
|     1 |    1 |
|     2 |    1 |
|     3 |    1 |
+-------+------+

But rather:

insert into fred values(1,1);
insert into fred values(2, 1);
insert into fred values(3, 1);

An example occurred today here and bluefeet's answer was excellent, however he wouldn't have had to write out INSERTs &c. had the OP done it for him. I know that this was a relatively trivial example, but it could save contributors here considerable time and trouble as well as increasing the value of dba.stackexchange as a site. Any takers?

5
  • 1
    Considering a good chunk of users will give you a blank look or the wrong output when you ask for this information, this request seems unrealistic.
    – Kermit
    Commented Jul 16, 2014 at 20:11
  • 1
    If they can't produce DDL and DML, perhaps they shouldn't be posting here at all? DBA is database administrator - I'd be seriously worried about anybody calling themselves a DBA if they can't produce simple scripts.
    – Vérace
    Commented Jul 16, 2014 at 20:14
  • 1
    I think you should take a look at how many of the users posting here are actually DBA's. Just because this site is called DBA's, doesn't mean you're a DBA.
    – Kermit
    Commented Jul 16, 2014 at 20:15
  • Well, OK, I fully accept that people weren't born knowing DDL and DML, but I did use the word "encouraged" - their posts could be rejected with a gentle hint on what they should be doing and a suggestion that they edit and resubmit?
    – Vérace
    Commented Jul 16, 2014 at 20:18
  • 2
    We do encourage this, all the time. Well, I don't know about the MySQL tags, but definitely in SQL Server. Asking for a SQLFiddle is usually better and easier than assuming they can whip up proper DDL and DML quickly. Of course it isn't always necessary, so I'm not really sure what you propose we do as a community other than keep on encouraging better information when the initial question isn't clear enough. And we already do that in a variety of ways, but mainly comments or putting it on hold.
    – Aaron Bertrand Staff
    Commented Jul 16, 2014 at 20:33

1 Answer 1

2

I agree 100% with Aaron's comment.

We will never be able to MANDATE that you do things a certain way, but as a community we can GUIDE those who post here.

There's a difference between people invested enough in the community to want to see change, and those who just show up to ask a question and leave again.

In this case you are advised to comment and guide askers and help them to be better members of our community, and by being friendly and engaging turn them into long term members of our community. At no time are you to DECLARE that they behave in a certain way.

On the occasion where they refuse to play nicely, flag the post for us and go on your way.

Never engage.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .