SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Feb 2009
    Posts
    994
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    information_schema - Count all columns from all tables

    Is there a way to Count all columns from all tables on one database, using the information_schema database ?

    Thanks,

    Dying,
    Márcio

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    MySQL?

    Code:
    SELECT COUNT(*) FROM COLUMNS WHERE table_schema = 'dbname'

  3. #3
    SitePoint Guru
    Join Date
    Feb 2009
    Posts
    994
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, I look but I didn't see the COLUMN table existence on information_schema database.

    The code provided would return a "no database found error" I believe, but this one will do it:

    Code MySQL:
    SELECT COUNT(*) FROM information_schema.COLUMNS WHERE table_schema = 'your_database_name';

    Thanks a lot,
    Márcio


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •