본문 바로가기
Database/DDL

not Null <=> Null 필드 양방향 변경 방법

by BAYABA 2021. 10. 10.
  1. 개인 공부 목적으로 작성한 글입니다.
  2. 아래 출처를 참고하여 작성하였습니다.

1. not Null 필드를 Null 허용 필드로 바꾸는 alter문

  1. 기존에 not null로 선언되어 있었던 updated_at (datetime) 필드를 null 허용 필드로 바꾸는 alter문
alter table ${TABLE_NAME} modify column `updated_at` datetime default null COMMENT '수정일시';

2. null 필드를 not Null 필드로 바꾸는 alter문

  1. 기존에 null로 선언되어 있었던 updated_at (datetime) 필드를 not null 필드로 바꾸는 alter문
alter table ${TABLE_NAME} modify column `updated_at` datetime not null COMMENT '수정일시';

출처

  1. MySQL) 테이블 not null -> null 허용가능으로 컬럼 변경하기, alter table

'Database > DDL' 카테고리의 다른 글

테이블 수정 관련 (ALTER)  (0) 2021.10.26
인덱스 생성, 삭제, 확인  (0) 2021.10.10