Unix Technical Forum

get all the columns on all the tables in information_schema

This is a discussion on get all the columns on all the tables in information_schema within the MySQL forums, part of the Database Server Software category; --> I am writing this query in PHPAdmin on the information_schema database. I want to get the column names from ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-29-2008, 09:41 AM
JRough
 
Posts: n/a
Default get all the columns on all the tables in information_schema

I am writing this query in PHPAdmin on the information_schema
database. I want to get the column names from all the tables. I can
figure out how to write the query for one table at a time. To save
time I would like to write it on all the tables but when I add tables
separated by a comma I get an error.

tia,

----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'table1', 'table2'
AND table_schema = 'myDatabase'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-29-2008, 09:41 AM
Jerry Stuckle
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

JRough wrote:
> I am writing this query in PHPAdmin on the information_schema
> database. I want to get the column names from all the tables. I can
> figure out how to write the query for one table at a time. To save
> time I would like to write it on all the tables but when I add tables
> separated by a comma I get an error.
>
> tia,
>
> ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> COLUMN_DEFAULT
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE table_name = 'table1', 'table2'
> AND table_schema = 'myDatabase'


.... WHERE table_name IN ('table1', 'table2') ...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-29-2008, 09:41 AM
Peter H. Coffin
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

On Tue, 27 May 2008 16:58:01 -0700 (PDT), JRough wrote:
> I am writing this query in PHPAdmin on the information_schema
> database. I want to get the column names from all the tables. I can
> figure out how to write the query for one table at a time. To save
> time I would like to write it on all the tables but when I add tables
> separated by a comma I get an error.
>
> tia,
>
> ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> COLUMN_DEFAULT
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE table_name = 'table1', 'table2'
> AND table_schema = 'myDatabase'


----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_schema = 'myDatabase'

--
Mares eat oats, and does eat oats, and little lambs eat ivy,
A kid will eat ivy too, wouldn't you?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-29-2008, 09:41 AM
Paul Lautman
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

JRough wrote:
>I am writing this query in PHPAdmin on the information_schema
> database. I want to get the column names from all the tables. I can
> figure out how to write the query for one table at a time. To save
> time I would like to write it on all the tables but when I add tables
> separated by a comma I get an error.
>
> tia,
>
> ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> COLUMN_DEFAULT
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE table_name = 'table1', 'table2'
> AND table_schema = 'myDatabase'


There is no such thing as PHPAdmin.

Do you mean phpMyAdmin?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-29-2008, 09:41 AM
JRough
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

On May 27, 5:53 pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Tue, 27 May 2008 16:58:01 -0700 (PDT), JRough wrote:
> > I am writing this query in PHPAdmin on the information_schema
> > database. I want to get the column names from all the tables. I can
> > figure out how to write the query for one table at a time. To save
> > time I would like to write it on all the tables but when I add tables
> > separated by a comma I get an error.

>
> > tia,

>
> > ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> > COLUMN_DEFAULT
> > FROM INFORMATION_SCHEMA.COLUMNS
> > WHERE table_name = 'table1', 'table2'
> > AND table_schema = 'myDatabase'

>
> ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> COLUMN_DEFAULT
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE
> table_schema = 'myDatabase'
>
> --
> Mares eat oats, and does eat oats, and little lambs eat ivy,
> A kid will eat ivy too, wouldn't you?


It would be nice if this would work because then I wouldn't have to
type in all the table names however, it does not work. This is the
error message and I double checked the database name spelling etc. It
stops where it starts processing the name of the database.
----------error-----
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_schema = 'dhan' at line 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-29-2008, 09:41 AM
JRough
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

On May 28, 2:00 am, "Paul Lautman" <paul.laut...@btinternet.com>
wrote:
> JRough wrote:
> >I am writing this query in PHPAdmin on the information_schema
> > database. I want to get the column names from all the tables. I can
> > figure out how to write the query for one table at a time. To save
> > time I would like to write it on all the tables but when I add tables
> > separated by a comma I get an error.

>
> > tia,

>
> > ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> > COLUMN_DEFAULT
> > FROM INFORMATION_SCHEMA.COLUMNS
> > WHERE table_name = 'table1', 'table2'
> > AND table_schema = 'myDatabase'

>
> There is no such thing as PHPAdmin.
>
> Do you mean phpMyAdmin?


Yes I am in phpMyAdmin/databases and I am in the SQL view with the
information_schema database selected.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-29-2008, 09:41 AM
Paul Lautman
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

JRough wrote:
> On May 27, 5:53 pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
>> On Tue, 27 May 2008 16:58:01 -0700 (PDT), JRough wrote:
>> > I am writing this query in PHPAdmin on the information_schema
>> > database. I want to get the column names from all the tables. I
>> > can figure out how to write the query for one table at a time. To
>> > save time I would like to write it on all the tables but when I
>> > add tables separated by a comma I get an error.

>>
>> > tia,

>>
>> > ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
>> > COLUMN_DEFAULT
>> > FROM INFORMATION_SCHEMA.COLUMNS
>> > WHERE table_name = 'table1', 'table2'
>> > AND table_schema = 'myDatabase'

>>
>> ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
>> COLUMN_DEFAULT
>> FROM INFORMATION_SCHEMA.COLUMNS
>> WHERE
>> table_schema = 'myDatabase'
>>
>> --
>> Mares eat oats, and does eat oats, and little lambs eat ivy,
>> A kid will eat ivy too, wouldn't you?

>
> It would be nice if this would work because then I wouldn't have to
> type in all the table names however, it does not work. This is the
> error message and I double checked the database name spelling etc. It
> stops where it starts processing the name of the database.
> ----------error-----
> #1064 - You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near 'COLUMN_DEFAULT
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE
> table_schema = 'dhan' at line 1


What is the IT that you are referring to? If you are referring to
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_schema = 'myDatabase'
then it works fine for me, in which case, you have made a mistake somewhere.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-29-2008, 09:41 AM
JRough
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

On May 27, 5:39 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> JRough wrote:
> > I am writing this query in PHPAdmin on the information_schema
> > database. I want to get the column names from all the tables. I can
> > figure out how to write the query for one table at a time. To save
> > time I would like to write it on all the tables but when I add tables
> > separated by a comma I get an error.

>
> > tia,

>
> > ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
> > COLUMN_DEFAULT
> > FROM INFORMATION_SCHEMA.COLUMNS
> > WHERE table_name = 'table1', 'table2'
> > AND table_schema = 'myDatabase'

>
> ... WHERE table_name IN ('table1', 'table2') ...
>
> --

The SQL doesn't appear to work.I tried it several times and included
the correct database name and table names:

COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name IN (
'Table1', 'Table2'
) AND table_schema = 'MyDatabase'

---------------error------------

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name
IN (
'INTERNAL_' at line 1


tia,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 05-29-2008, 09:41 AM
Paul Lautman
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

JRough wrote:
> On May 27, 5:53 pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
>> On Tue, 27 May 2008 16:58:01 -0700 (PDT), JRough wrote:
>> > I am writing this query in PHPAdmin on the information_schema
>> > database. I want to get the column names from all the tables. I
>> > can figure out how to write the query for one table at a time. To
>> > save time I would like to write it on all the tables but when I
>> > add tables separated by a comma I get an error.

>>
>> > tia,

>>
>> > ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
>> > COLUMN_DEFAULT
>> > FROM INFORMATION_SCHEMA.COLUMNS
>> > WHERE table_name = 'table1', 'table2'
>> > AND table_schema = 'myDatabase'

>>
>> ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
>> COLUMN_DEFAULT
>> FROM INFORMATION_SCHEMA.COLUMNS
>> WHERE
>> table_schema = 'myDatabase'
>>
>> --
>> Mares eat oats, and does eat oats, and little lambs eat ivy,
>> A kid will eat ivy too, wouldn't you?

>
> It would be nice if this would work because then I wouldn't have to
> type in all the table names however, it does not work. This is the
> error message and I double checked the database name spelling etc. It
> stops where it starts processing the name of the database.
> ----------error-----
> #1064 - You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near 'COLUMN_DEFAULT
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE
> table_schema = 'dhan' at line 1


According to your first post, you knew all about normalising and SELECT
queries.

On 23rd May, you promised to actually learn the basics of SQL.

You seem to be trying to run before you can walk. Please do us all a favour
and read the sodding manual and learn how to program SQL.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-29-2008, 09:41 AM
Paul Lautman
 
Posts: n/a
Default Re: get all the columns on all the tables in information_schema

JRough wrote:
> On May 27, 5:39 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> JRough wrote:
>> > I am writing this query in PHPAdmin on the information_schema
>> > database. I want to get the column names from all the tables. I
>> > can figure out how to write the query for one table at a time. To
>> > save time I would like to write it on all the tables but when I
>> > add tables separated by a comma I get an error.

>>
>> > tia,

>>
>> > ----------------SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE,
>> > COLUMN_DEFAULT
>> > FROM INFORMATION_SCHEMA.COLUMNS
>> > WHERE table_name = 'table1', 'table2'
>> > AND table_schema = 'myDatabase'

>>
>> ... WHERE table_name IN ('table1', 'table2') ...
>>
>> --

> The SQL doesn't appear to work.I tried it several times and included
> the correct database name and table names:
>
> COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name IN (
> 'Table1', 'Table2'
> ) AND table_schema = 'MyDatabase'


Please can you post the FULL query that you are executing. We can't tell you
anything if you only post part of it.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:37 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com