Edit: try again.

In a SQL related question, when the OP gives a code table such as:

Department   | Category  | 
0001         | A         |
0002         | D         |
0003         | A         | 
0003         | A         |
0003         | C         |
0004         | B         |

It would save time for someone answering to be able to click a button in SO and be linked to a SQL DDL script that would actually create the table for them, if they pasted it into their favourite db admin program, i.e. generates Shannon's code:

create table T (
    Department varchar(10) null,
    Category varchar(10) null

-- Original test case
insert into T values ('0001', 'A');
insert into T values ('0002', 'D');
insert into T values ('0003', 'A');
insert into T values ('0003', 'A');
insert into T values ('0003', 'C');
insert into T values ('0004', 'B');
-- Null Test cases:
insert into T values (null, 'A');
insert into T values (null, 'B');
insert into T values (null, 'B');
insert into T values ('0005', null);
insert into T values ('0005', null);
insert into T values ('0005', 'X');
-- Tie Test case
insert into T values ('0006', 'O');
insert into T values ('0006', 'P');

It occurred to me after posting a simple SQL table example that it would be a useful timesaving device to have a also posted a create table DDL script so that it was easier to work/test on. Often though you post pseudo-data rather than real columns, so I was thinking about a code syntax that the OP could use and then others could click a button to generate the SQL CREATE TABLE syntax for the schema and for the data. See Shannon Severance's answer to the question for sample code, generated from what could be a CSV-ish syntax - need to preserve the readability which is why commas aren't a good idea, but: first line headers, everything else data, trimmed and bars removed:

Department   | Category  | 
0001         | A         |
0002         | D         |
0003         | A         | 
0003         | A         |
0003         | C         |
0004         | B         |

Just seemed a useful timesaver and an incentiviser to get into the question.

  • I'm with TheTXI; does not compute. From what I can tell you're asking for some sort of scripting language to create tables...? Or somehow turn your ASCII table into a INSERT query? Seems out of the question. – Ian Elliott Jul 30 '09 at 19:34
  • just use sqlfiddle! (but remember to include the full schema in your question alongside your link) – Graham Griffiths Aug 7 '13 at 16:25

I feel like I'm reading some sort of Sphinx riddle that has been poorly translated from Greek. But, if I understand correctly, you're proposing that the system auto-generate SQL statements to create and populate a database table based upon an ASCII sketch.

Why would that be a worthwhile use of the developers' time? Not only is it a non-trivial task, it's one with limited usefulness. Next I suppose you'll be asking for the system to compile and run code blocks and include their output. I don't support this in the least. If you really think people will need the SQL statements, provide them. That's part of writing a good question.

I can't stress this enough, people: StackOverflow is not a replacement for putting forth effort.

  • What if someone posts a complete database of a pokedex. God damn, the amount of sleepless nights I have spent wishing for such data in a single, convenient SQL query. – Ian Elliott Jul 30 '09 at 19:46
  • A wild Abra appears – Welbog Jul 30 '09 at 19:47
  • @Welbog: That thing's going to Teleport before I can catch it! Why doesn't SO have a feature to put Pokemon to sleep? – Hilarious Comedy Pesto Jul 30 '09 at 19:48
  • Abra is eaten by Kirby. Kirby gains +1 Abra. – Welbog Jul 30 '09 at 19:50
  • No idea whether to accept this answer or just delete the question and go hide in a cave. Lesson learned, don't suggest anything "costly", write your own solution and fragment everything further. – Alistair Knock Jul 31 '09 at 22:37

I'm honestly not even sure what the heck you are asking for.

I do know that Jeff has said repeatedly that he does not want to include <table> </table> markup to create tables in the editor, but if you are suggesting some method to easily create ASCII tables (like the create-table tool in MS Word) then I would be for that. Everything else you were talking about with SQL Create Table syntax was just a blur and made no sense to me.


I have no idea what this question is about so here's something that seems related:

Pbwiki (and surely other wiki providers) has a syntax for laying out tables automatically which is really easy to use and intuitive:

Every table starts with a pipe following a space, every column is delimited by a pipe, and every row is delimited by a space. So, for example, the following text entered into the text box:


Would yield the following structure:


Which lets people define table structures easily without giving them full control over the table, row and cell tags which is what I'm assuming Jeff wants to avoid most of all.

  • Jeff has denied requests to provide this functionality. It's probably your fault. – Hilarious Comedy Pesto Jul 30 '09 at 19:42
  • Jeff is such a jerk. – Welbog Jul 30 '09 at 19:43
  • moooooom, Jeff isn't letting me play with tables again – Ian Elliott Jul 30 '09 at 19:47
  • This answer was just an elaborate excuse to post ASCII Kirby anyway. – Welbog Jul 30 '09 at 19:48
  • @Ian: No tables until you finish your broccoli, mister! – Hilarious Comedy Pesto Jul 30 '09 at 19:52

You must log in to answer this question.

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