Using INFORMATION_SCHEMA Tables
mysql>
mysql> CREATE TABLE mytable (
-> titleID INT NOT NULL AUTO_INCREMENT,
-> title varchar(100),
-> PRIMARY KEY (titleID)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> SELECT column_name, ordinal_position, column_default,
-> data_type, collation_name
-> FROM information_schema.columns
-> WHERE table_schema="test" AND table_name="mytable";
+-------------+------------------+----------------+-----------+-------------------+
| column_name | ordinal_position | column_default | data_type | collation_name |
+-------------+------------------+----------------+-----------+-------------------+
| titleID | 1 | NULL | int | NULL |
| title | 2 | NULL | varchar | latin1_swedish_ci |
+-------------+------------------+----------------+-----------+-------------------+
2 rows in set (0.01 sec)
mysql>
mysql> drop table mytable;
Query OK, 0 rows affected (0.00 sec)
mysql>
Related examples in the same category