[mysql] alter table after 필드

DB 2016. 11. 16. 10:48

테이블에서 새로운 필드를 추가하려면 아래와 비슷한 타입으로 쓴다. 


alter table tableName add column columnName not null


이 때, 맨 마지막 컬럼에 위치하게 되므로 원하는 모델이 되지 않을 수 있다.


순서를 특정 컬럼 다음에 위치하려면, after를 사용한다. 



alter table tableName add column columnName not null after preColumnName


뿐만 아니라 first도 사용할 수 있다.





자세한 내용은 http://dev.mysql.com/doc/refman/5.7/en/alter-table.html를 참고한다.


To add a column at a specific position within a table row, use FIRST or AFTER col_name. The default is to add the column last. You can also use FIRST and AFTER in CHANGE or MODIFY operations to reorder columns within a table.


'DB' 카테고리의 다른 글

[derby] validation query  (0) 2017.04.10
[mysql] auto increment 이슈  (0) 2016.12.19
[mysql] SELECT .. INTO OUTFILE  (0) 2016.04.16
[mysql] INSERT INTO .. VALUES ON DUPLICATE KEY UPDATE.. 응답 값  (0) 2016.03.31
[MySQL] GROUP_CONCAT  (0) 2016.02.15
Posted by '김용환'
,