mysql 'show create table' on several tables - mysql

I have to get the SHOW CREATE TABLE tblName output of all the tables and write it to files (one file for each table).
Anyone can help me how I can begin to this? I suppose stored procedures? I am pretty sure that there is a tutorial I can follow because MySQL has a big community..
Thanks in advance
Some pictures of the output I need of each table:

Since your screenshot shows that you're using Windows; you can use HeidiSQL for your task.
There's an option in tools, titled Export database as SQL.

Related

How to export from mysql database to database document table definition book

My problem is that I am getting a mysql database with lots of tables. And the need to output the same document as the file I attach, Is there any tool that supports this?
Thanks so much.
The information you want is in the INFORMATION_SCHEMA.COLUMNS table, or the output of SHOW COLUMNS.
there is a tool to select the column from each table you want to extract on excel.
check Microsoft tutorial
you should obtain this menu :
enter image description here
and you just drop the column you want

How do I generate a new table to a DB using SQL in phpmyadmin?

I'll guess the headline pretty much covers my question, however to elaborate on my question a bit further in order to avoid any confusion, I can say that I have found a ready-made table which is in SQL and it is this SQL I would like to know whether or not it is possible to just paste it into phpmyadmin in order to generate the table ?
Thank you in advance
After selecting the database you want to insert your table into, click the "SQL" tab. Then you can paste your SQL right there and that will generate your table for you - provided the SQL is correct.
If you have any trouble, feel free to post your SQL and we'll have a look.
Try the import function on top, select your sql file there. This should create your table which is coded in the sql file.

MySQL Replace table from another table

I have 2 active database connections, I need to replace a number of tables from 'connection1' with that of connection2. The structures may, or may not be same, (depending if we make changes to the connection1 table.
I would assume I should do a complete table dump and replace keys where neccesary, but I really have no idea how to do this :)
Any help?
Have a look at Schema and Data sync tools in dbForge Studio for MySQL. It will help you to compare two databases on different servers, map tables and fields, generate and run synchronization script.
I ended up using the build in system command in PHP and mysqldump to first dump the data (export) to a file, then used system() again with mysql to import it into the new table and replace the old one.
Works like a charm :)

Retrieve Comments from tables and columns in a Mysql database

i have to build an application to manage an existing MySQL database. This database was created with MySQLworkbench and some useful comments were added to its tables and columns.
I think it would be great to somehow, query that comments and show them to the user to explain "what that field is". The problem is i don't know if its possible to retrieve that comments (they are only visible from the workbench).
EDIT:
in the MySQL existing database i have to work with there is no INFORMATION_SCHEMA table. I think is something usual to find it but in my model there is no :S
Try with:
SELECT column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='table_name';
You can parse the output of
show create table `YOURTABLE`;

How can I make tables in MySQL?

I have two distinct scenarios.
One, where there is a many to many case, you must create a third table. But I'm not familiar with MySQL syntaxis.
Two, is this one:
How can I declare using SQL code?
In MYSQL my create tables using the CREATE TABLE command. If you don't feel too confident to write your tables with that syntax, I'd suggest using a tool like the MySQL Workbench. That tool can greatly help you there.
You need to have a look at CREATE TABLE Syntax