Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Finding out about columns

Posted by enquirer (enquirer), 25 September 2002
How do I find what the columns in a table are called and what type of fields they are?

Posted by admin (Graham Ellis), 25 September 2002
SHOW COLUMNS does that for you ... (it's one of those little things that everyone keeps forgetting )

Here's an example of it in use, via the mysql client:

Code:
$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18 to server version: 3.23.22-beta

Type 'help' for help.

mysql> use H201;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show columns from users;
+-----------+-------------+------+-----+---------+----------------+---------------------------------+
| Field     | Type        | Null | Key | Default | Extra          | Privileges                      |
+-----------+-------------+------+-----+---------+----------------+---------------------------------+
| id        | int(11)     |      | PRI | NULL    | auto_increment | select,insert,update,references |
| username  | varchar(16) |      |     |         |                | select,insert,update,references |
| password  | varchar(13) | YES  |     | NULL    |                | select,insert,update,references |
| full_name | text        | YES  |     | NULL    |                | select,insert,update,references |
+-----------+-------------+------+-----+---------+----------------+---------------------------------+
4 rows in set (0.05 sec)

mysql> exit;
Bye
$


Later note - OUCH - that displays nasty.  Think I've a problem with cut and paste, tabs and spaces.  Try oit on your own MySQL tables, and you'll find it looks very neat!

Posted by John_Moylan (jfp), 25 September 2002
does: "desc column_name" do the same thing?

jfp

Posted by admin (Graham Ellis), 25 September 2002
Basically, yes.   I understand that "desc" and "describe" don't add any extra functionallity to what you can do with show.   They're just there to be provide something that Oracle users might be familiar with coding.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho