sql 문 이것 저것 모음

Jaehyung Baik·2023년 8월 28일
0

SQL

목록 보기
2/2

자바 웹개발 워크북으로 공부중 잘 안쓰는 sql문 정리

  1. 재귀 복사 (현재 데이터 X2가 된다.)

insert into 테이블명 (컬럼이름, ...) (select 컬럼이름, ... from 테이블명);

    1. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences 에러 해결.

set sql_safe_updates=0;
delete from 테이블명;
테이블의 데이터 모조리 삭제.
테이블명 뒤에 where 절로 조건을 붙여도 됨.

  1. count

select count(*) from 테이블명;
* 자리에는 컬럼이름을 쓰든 * 을 넣든 뭐라도 넣어야 카운팅된다.

  1. auto_increment 초기화

alter table tbl_todo auto_increment=1;

현재 데이터 다음숫자로 초기화 현재 데이터를 1부터로 만드는 법은 모름.

profile
dataXdata=DATA

0개의 댓글

관련 채용 정보