Using INFORMATION_SCHEMA Tables : INFORMATION_SCHEMA « Command MySQL « SQL / MySQL






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

1.Check schema name
2.Check the table name with schema name
3.Check characgter set name and collation name
4.Check the CHARACTER_SET_NAME in INFORMATION_SCHEMA.COLLATIONS
5.Show the names of the tables that are stored in the INFORMATION_SCHEMA database.
6.Check information for stored procedures by the table information_schema.routines.
7.Schema of information_schema Tables
8.Check table schema for schema table