카테고리 없음

[Maria DB] auto_increment

worri-pi 2021. 12. 25. 02:22

 

-auto_increment는 항상 기본키로 지정해야 한다.

 

1. database로 들어가기

use 데이터베이스명;

2.

create table t_board(board_seq int auto_increment primary key);
alter table t_board auto_increment='default value'; or 
alter table t_board modify board_seq int not null auto_increment primary key;

 

고유키를 두 개 이상 지정하기 위해서는 다음과 같이 입력하면 된다.

create table t_board (testno int, testnu int, primary key(testno,testnu));

 

728x90