Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:26:39+00:00 2026-06-10T07:26:39+00:00

When I need to ask a mySQL database schema question – I try and

  • 0

When I need to ask a mySQL database schema question – I try and “write” out my table schema – but its quite long.

so I checked SO – but I couldnt find an answer: is there a way to automatically generate an ASCII style database schema from mySQL (or phpmyadmin) automatically?

I.e. I want to get something like this automatically:

+----------+---------+----------------------------+
|  user_ID | user    |   roles                    |
+----------+---------+----------------------------+
|        1 |   Smith |    1                       |
+----------+---------+----------------------------+
|        2 |   Jones |    1                       |
+----------+---------+----------------------------+

how do people do it? What is the best way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:26:41+00:00Added an answer on June 10, 2026 at 7:26 am

    Am not certain phpMyAdmin can do what you want, but you can get exactly this by using the mysql prompt. Here’s how:

    Assuming you want just the schema of a table my_table.

    Open a terminal and run mysql passing in the username (-u) and password (-p) if required. On windows, you might want to ensure that the mysql bin directory is on the path (if you are working on Windows, you might also want to have mysql on the PATH).

    Once you have a mysql terminal;

    you might want to see which databases are available:

    show databases;
    

    Select the database to use:

    use this_database;
    

    You might also wish to see which tables are available (in this database):

    show tables;
    

    Now, to see the schema / definition of a table e.g my_table, run the following command:

    describe my_table;
    

    That should get you an ASCII-pretty-printed ouput like this for example:

    +--------------------+--------------+------+-----+---------+----------------+
    | Field              | Type         | Null | Key | Default | Extra          |
    +--------------------+--------------+------+-----+---------+----------------+
    | id                 | int(11)      | NO   | PRI | NULL    | auto_increment |
    | name               | varchar(50)  | NO   |     | NULL    |                |
    | location_id        | int(11)      | NO   | MUL | NULL    |                |
    | manager_id         | int(11)      | NO   | MUL | NULL    |                |
    | other              | varchar(100) | YES  |     | NULL    |                |
    | creation_timestamp | datetime     | NO   |     | NULL    |                |
    | is_active          | tinyint(1)   | NO   |     | NULL    |                |
    +--------------------+--------------+------+-----+---------+----------------+
    

    In case it’s the schema+data that you want, then you are probably settling for the column names, and whatever rows you want, with a SELECT query. For example something like this:

    SELECT * FROM stores LIMIT 2;
    

    Will give the following:

    +----+------------+-------------+------------+-------+---------------------+-----------+
    | id | name       | location_id | manager_id | other | creation_timestamp  | is_active |
    +----+------------+-------------+------------+-------+---------------------+-----------+
    |  1 | Good Store |           1 |          1 |       | 2012-06-17 19:14:15 |         1 |
    |  2 | Neu Store  |           2 |          1 |       | 2012-06-29 05:14:24 |         1 |
    +----+------------+-------------+------------+-------+---------------------+-----------+
    

    NOTE : In all the above examples, mysql will surely get you the output as I’ve shown (unless if paging or the orientation is changed), but gor you to then copy and paste this output onto SO, you need to copy and paste from the terminal / console; on standard linux/unix terminals, you can select the output using the mouse, and then copy it onto the clipboard using Control+Shift+C, then paste it onto SO. On windows, after selecting with the mouse, I think u can then right click and select copy or you need to select mark from the console window, and then select the output, after which it should be automatically available on the clipboard for you to paste on SO.

    Also, when you paste the output into the textbox on SO, don’t forget that for SO to display it as code, you need to select the content, and then click the {} to have it formatted as code. Alternatively, just left-indent it with 4 spaces for each line.

    Hope this resolves you problem, though it’s not as automatic as you might have wished for, but I believe a script using something like xclip and the mysql commands could get close to this, done automatically 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this sounds like a dumb question but I need to ask this.
This question is quite hypothetical but I'll ask anyway. Let's say you start a
I am sure it is a silly question to ask. But i need help
Why you may ask? Because i have built the app on mysql and need
I have a SQL question that i need to ask the experts. To be
Don't ask me why but I need to do the following: string ClassName =
Somebody ask me this question today . What is the need of reference in
I know, I know, title is quite bad, but I'll try to explain what
I need to complete the plan of a ask-a-question site for my uni. in
I have a directory table in a MySQL database that contains user ID's, user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.