Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

You can Add a comment or ranking to this page

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