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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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' |
| |||
| 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 ================== |
| |||
| 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? |
| |||
| 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? |
| |||
| 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 |
| |||
| 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. |
| |||
| 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. |
| |||
| 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, |
| |||
| 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. |
| ||||
| 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. |