Mac [MariaDB] 14.primary key

델버·2022년 5월 19일
0

MariaDB

목록 보기
15/17

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;

0개의 댓글