--형식--
CREATE TABLE tablename
(
column_name data_type,
column_name data_type
);
-------
--EX--
create table cats(
name varchar(100),
age int
)
SHOW TABLES
mysql> show tables;
+-------------------+
| Tables_in_cat_app |
+-------------------+
| cats |
+-------------------+
1 row in set (0.00 sec)
It tells us that there is a cat table but that's pretty much it doesn't say anything about the contents of that table what are the different columns init.
SHOW COLUMS FROM <TABLE NAME>
mysql> show columns from cats;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| age | int | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
or, use DESCRIBE <TABLE NAME>
, DESC <TABLE NAME>
mysql> describe cats;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| age | int | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> desc cats;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| age | int | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
차이점은 없다.