
- table 생성 시 고유값, primary key을 만들 수 있다
create table tableName(
column1 속성,
column2 속성2...,
primary key (column1)
- primary key는 null을 포함할 수 없으며, 해당 테이블의 고유값으로 설정된다
- primary key는 두 개의 컬럼을 하나로 묶어서 만들 수 있다
create table tableName(
column1 속성,
column2 속성2...,
primary key (column1, column2...)

- 만든 primary key를 확인하기 위해 table을 보니 정상적으로 고유값이 설정되어 있다.

- 생성한 테이블에서 key값을 삭제하고 싶을 때는 alter문법으로 삭제가 가능하다
alter table tableName drop primary key

- key값 중 foreign key는 다른 table의 column과 연결하여 식별할 수 있는 key값이다.
create table tableName(
column1 속성,
column2 속성,
primary key (column1...),
constraint keyName foreign key (column1) references table2(column1)
- constraint 값은 지정하지 않을 시 자동적으로 만들어지고, 직접 입력할 경우 foreign key 이름을 지정할 수 있다.

show create table tableName
- 위 명령문을 통해 해당 테이블의 foreign 이름을 알 수 있다.

- 생성한 foreign key값은 alter문법을 통해 삭제할 수 있다.
alter table tableName drop foreign key foreignName
- primary key은 고유값이기에 별도의 KeyName을 넣지 않아도 알아서 삭제되지만, foreign key는 이름을 넣어 삭제해야한다.

- 이미 만들어진 table에 foreign key를 넣을 수도 있다
alter table tableName add foreign key (column) references table2(column)

- 두 개 table을 foreign 연결하기 위해 column을 수정함

- crime_status의 police_station data를
- concat("서울", crime_status.police_station, "경찰서")로 합칠 경우 police.name과 같은 형태가 되는 것을 확인했다.

- 먼저, 안정적인 table작업을 위해 police_station에 key값을 설정

- 이후 crime_status에 reference 변수를 추가 후
- crime.status의 reference와 police_station.name foreign key로 연동

- 그리고 crime_status의 reference data를 police_station의 name값을 입력
-
- 경찰서별로 해당 주소를 정리