Re: MariaDB Database / Table Structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




This is extremely helpful.  Thank you very much.

SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA="'.$val.'"
* where $val is a database



On Wednesday November 5 2014 2:14 AM, Roberto Spadim wrote:
with mariadb/mysql:

2014-11-05 4:20 GMT-02:00 Ron Piggott <ron.piggott@xxxxxxxxxxxxxxxxxx <mailto:ron.piggott@xxxxxxxxxxxxxxxxxx>>:


    Hi Everyone.

    I am wondering if there are database queries that would


SHOW DATABASES; <- return all databases

    a: produce the result of all the tables with a database *

SHOW TABLES FROM `database_name`;
or
USE `database_name`;
SHOW TABLES;
or
use infomration schema:
*SELECT * FROM information_schema.TABLES*
or
*SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES*
or
*SELECT DISTINCT TABLE_SCHEMA,TABLE_NAME FROM information_schema.COLUMNS*
*
*

    b: produce the result of all the columns with the specified
    database table *

SELECT * FROM `database_name`.`table_name` LIMIT 0? (and fetch fields names via php functions of result set)
or
SHOW FIELDS FROM `database_name`.`table_name`;
or
*SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA="database_name" AND TABLE_NAME="table_name"; (and interact as a result set)*



    * I don't want any other details than these names.

    I am trying to build a WHILE loop that in pseudo code will look
    roughly like

    - query to get a list of all the tables within a database
    - start of a foreach loop (going one table at a time

       - query to get all the column names within the table
       - start of a foreach loop to display column names
       - display column name
       - end of foreach loop

    -end of foreach loop

    Ron

this sounds like a table structure dump to execute a diff, i'm right?


--
Roberto Spadim
SPAEmpresarial
Eng. Automação e Controle


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux