+++ ȨÁ¦ÀÛ ¹ÙÀ̺í +++
ȨÁ¦ÀÛ ¹ÙÀ̺í ÀÌ »çÀÌÆ®´Â ÀÌ¿µÂù´ÔÀÇ »çÀÌÆ®¸¦ º¹¿øÇÑ °ÍÀÔ´Ï´Ù.
Untitled Document
Html
Dhtml
Css
Php
Asp
Cgi
Java Script
Java Applet
Multimedia
Win Tip
Mysql - Å×ÀÌºí±¸Á¶ ´Ù·ç±â

@ Å×ÀÌºí¸¸µé±â - Å×À̺í À̸§ : test

mysql> create table test(a int,b char(20));
Query OK, 0 rows affected (0.09 sec)

mysql> desc test;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.01 sec)


@ Å×À̺í À̸§ ¹Ù²Ù±â - ¹Ù²Ü À̸§ : test2

mysql> alter table test rename as test2;
Query OK, 0 rows affected (0.00 sec)

mysql> desc test2;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.01 sec)

@ ÇʵåÃß°¡Çϱâ : c ÇʵåÃß°¡

mysql> alter table test2 add c int;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
| c     | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

@ ÇʵåÃß°¡ - ¿øÇÏ´Â À§Ä¡¿¡»ðÀÔÇϱâ (mysql ¹öÁ¯ 3.22 ÀÌÈÄ ¹öÁ¯¸¸ Áö¿ø)

mysql> alter table test2 add d int after a;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| d     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
| c     | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

@ Çʵå»èÁ¦ - d ÇÊµå »èÁ¦Çϱâ

mysql> alter table test2 drop d;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
| c     | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

@ ÇÊµå ¼Ó¼º ¹Ù²Ù±â - c Çʵ带 À̸§ d ·Î ¹Ù²Ù°í ŸÀÔÀ» char·Î ¹Ù²Ù±â

mysql> alter table test2 change c d char;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
| d     | char(1)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.01 sec)

@ d ÇʵåÀÇ Å¸ÀÔÀ» int·Î ¹Ù²Ù±â

mysql> alter table test2 change d d int;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(20) | YES  |     | NULL    |       |
| d     | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
Update : 2000/05/17 [µ¹¾Æ°¡±â]