CREATE 는 이전 글에서 이미 해보았다.
기존의 cat테이블을 삭제하고 새로 만들어주고, 데이터를 추가해준다.
mysql> create table cats(
-> cat_id int not null auto_increment,
-> name varchar(100),
-> breed varchar(100),
-> age int,
-> primary key(cat_id)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql> desc cats;
+--------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+----------------+
| cat_id | int | NO | PRI | NULL | auto_increment |
| name | varchar(100) | YES | | NULL | |
| breed | varchar(100) | YES | | NULL | |
| age | int | YES | | NULL | |
+--------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
mysql> INSERT INTO cats(name, breed, age)
-> VALUES ('Ringo', 'Tabby', 4),
-> ('Cindy', 'Maine Coon', 10),
-> ('Dumbledore', 'Maine Coon', 11),
-> ('Egg', 'Persian', 4),
-> ('Misty', 'Tabby', 13),
-> ('George Michael', 'Ragdoll', 9),
-> ('Jackson', 'Sphynx', 7);
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0