티스토리 뷰
728x90
반응형
select last_insert_id(); // 마지막으로 insert한 id(no)를 가져옴
show full columns from 테이블명 ; // 테이블 컬럼들에대한 자세한 정보가 나옴
show tables; // DB의 테이블목록 출력
select * from information_schema.table_constraints where table_name = '테이블명'; // 테이블의 제약조건명을 볼수있음
alter table 테이블 이름 auto_increment=1; // auto_increment 재설정
alter table 테이블 이름 modify column 컬럼명 컬럼 타입; // 컬럼 속성 변경
alter table 테이블 이름 add constraint 제약조건이름(아무거나) foreign key (외래키컬럼이름) references 참조할테이블( 참조할 테이블의 pk) on delete set null;
다양한 옵션
on delete cascade
on delete restrict
alter table 테이블 이름 drop foreign key 제약조건명; // 외래키 삭제
728x90
반응형
'DataBase' 카테고리의 다른 글
[DB] index 사용시 주의할점 (0) | 2019.05.14 |
---|---|
[MySQL] workbench 연결시간 늘리는방법 (0) | 2019.05.13 |
DB 팁 (0) | 2019.04.10 |
Index에 대한 이야기 (0) | 2019.04.04 |
댓글