0

Forgive me if this is a meta question - if so I'll quickly move it.

I would like to be able to output a table structure in the format often used on SO, so that when I post questions, I don't have to do time consuming reformatting. I've often seen something like this on SO:

+--------------+------------------+
| Field        | Type             |
+--------------+------------------+
| userid       | int(10)          |
| firstname    | varchar(50)      |
| lastname     | varchar(50)      |
+--------------+------------------+

How do you do it?

I am using phpmyadmin under Windows but don't mind using a mysqldump statement, or even a php script.

Using the statement "Describe table" under phpmyadmin gives the table but obviously not formatted for posting.

Using mysqldump gives me only create statements

mseifert
  • 5,390
  • 9
  • 38
  • 100
  • http://dev.mysql.com/doc/refman/5.6/en/explain.html (it's for command line though) – zerkms Feb 17 '15 at 00:28
  • 2
    I use this: http://www.sensefulsolutions.com/2010/10/format-text-as-table.html – Marty Feb 17 '15 at 00:34
  • 2
    Personally, I much prefer if you post the `SHOW CREATE TABLE` for the tables relevant to your question. I can visualize that just as easily and i can use it to help create an answer for you without having to manually create a schema. – prodigitalson Feb 17 '15 at 00:34
  • @zerkms - When I use the explain syntax on the command line, it works fine. As soon as I attempt to pipe the output to a file using `mysql --user=*** --password=*** database < explain.sql > output.txt` it strips all the formatting. Guess I'll have to take this output and run it through the link that Marty posted if I want it formatted. Or take the advice of prodigitalson and simply use the `create table` syntax. – mseifert Feb 17 '15 at 01:38
  • I agree with @prodigitalson -- in particular, that makes it easy for me to recreate your database structure on my testing system. A pretty-looking table is okay for communicating content but makes it more work for me to reproduce it. – Isaac Bennetch Feb 17 '15 at 20:31
  • @prodigitalson - got it. I was just going off of what I have seen most often. I'm happy to make it easier for everyone - including myself. Thanks for responding. – mseifert Feb 17 '15 at 21:20
  • @IsaacBennetch - Thanks for weighing in. I will post the create statements from now on. – mseifert Feb 17 '15 at 21:21

0 Answers0