본문 바로가기
DB/MariaDB

[MariaDB] 14.primary key

by 델버 2022. 12. 20.

primary key 기본키

  • table당 한 개만 존재한다.
  • unique + not null

설정

  • alter table table명 add constraint primary key(column명);
  • alter table table명 modify column명 자료형 primary key;

제거

  • alter table table명 drop primary key;
  • alter table table명 drop constraint column명;
  • (not null은 제거 안 됨)
    alter table table명 modify column명 자료형 null;

→ 만약 auto_increment가 걸려있다면 먼저 제거를 하고 그 다음 진행해야 한다.

  • alter table table명 modify column명 자료형 not null;
  • alter table table명 drop primary key;

댓글