๐พ[MySQL] ์ปฌ๋ผ๋ช ๋ณ๊ฒฝ, ์์๋ณ๊ฒฝ, ํ์ ๋ณ๊ฒฝ, ์ถ๊ฐ.
์ปฌ๋ผ๋ช ๋ณ๊ฒฝ
- ALTER TABLE ${ํ ์ด๋ธ๋ช } CHANGE ${๊ธฐ์กด์ปฌ๋ผ๋ช } ${๋ณ๊ฒฝํ ์ปฌ๋ผ๋ช } ${์ปฌ๋ผํ์ };
mysql> ALTER TABLE user CHANGE user_id user_name varchar(30);
์ปฌ๋ผ ์์๋ณ๊ฒฝ
- ALTER TABLE ${ํ ์ด๋ธ๋ช } MODIFY ${์์๋ณ๊ฒฝํ ์ปฌ๋ผ๋ช } ${์ปฌ๋ผํ์} AFTER ${์์์ค๋์ปฌ๋ผ๋ช };
ALTER TABLE usr MODIFY nickname varchar(64) AFTER user_id;
์ปฌ๋ผ ๋ํดํธ๊ฐ ๋ณ๊ฒฝ
- ALTER TABLE ${ํ ์ด๋ธ๋ช } ALTER COLUMN ${๋ณ๊ฒฝํ ์ปฌ๋ผ๋ช } SET DEFAULT ${๋ํดํธ๊ฐ};
ALTER TABLE user ALTER COLUMN time SET DEFAULT 24;
์ปฌ๋ผ ํ์ ๋ณ๊ฒฝ
- ALTER TABLE ${ํ ์ด๋ธ๋ช } MODIFY ${์ปฌ๋ผ๋ช } ${๋ณ๊ฒฝํ ์ปฌ๋ผํ์ };
mysql> ALTER TABLE user MODIFY user_id INT(10);
์ปฌ๋ผ ์ถ๊ฐ
- ALTER TABLE ${ํ ์ด๋ธ๋ช } ADD ${์ถ๊ฐํ ์ปฌ๋ผ๋ช } ${์ปฌ๋ผํ์ } DEFAULT ${๋ํดํธ๊ฐ};
- ALTER TABLE ${ํ ์ด๋ธ๋ช } ADD COLUMN ${์ถ๊ฐํ ์ปฌ๋ผ๋ช } ${์ปฌ๋ผํ์ } DEFAULT ${๋ํดํธ๊ฐ} ${์ปฌ๋ผ์์น};
mysql> ALTER TABLE user ADD level int DEFAULT 1;
mysql> ALTER TABLE 'rank' ADD COLUMN 'ranking' INT(10) DEFAULT 0 AFTER 'user_id'; // user_id ๋ค์ ์ถ๊ฐ
mysql> ALTER TABLE 'rank' ADD COLUMN 'test' INT(10) DEFAULT 1 FIRST; // ํ
์ด๋ธ ๋งจ ์์ ์ถ๊ฐ