블로그 이미지
암초보

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

Tag

05-18 22:35
2013. 11. 29. 14:42 DB/MySQL

INSERT 시 PK가 중복되면 무시하는 것.


INSERT IGNORE INTO... 이렇게 INSERT와 INTO사이에 IGNORE 만 넣어주면된다.



그 외 


INSERT문 끝에 ON DUPLICATE KEY를 사용하여

키 중복시 Update를 사용할 수도 있음..

posted by 암초보
2013. 11. 27. 12:58 프로그래밍/Servlet&JSP

varStatus를 이용한다.

예시)

<c:forEach varStatus="status .........>

${status.index} 또는 ${status.count}

index는 0부터 count는 1부터

'프로그래밍 > Servlet&JSP' 카테고리의 다른 글

fmt:parseDate 와 fmt:formatDate  (0) 2013.05.20
URLDecoder  (0) 2009.08.05
JSP 쿠키 생성, 삭제  (0) 2009.08.04
posted by 암초보
2013. 10. 31. 17:35 DB/MySQL

mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt -u계정 -p 데이터베이스이름 > 백업할 파일이름

'DB > MySQL' 카테고리의 다른 글

selecting top N records per group  (0) 2014.08.12
INSERT IGNORE  (0) 2013.11.29
The Rows Holding the Group-wise Maximum of a Certain Column  (0) 2013.10.23
datadir 변경에 대한 답변  (0) 2013.09.25
SELECT 결과 INSERT하기  (0) 2013.09.12
posted by 암초보
2013. 10. 31. 17:26 프로그래밍/Java
posted by 암초보
2013. 10. 31. 13:56 프로그래밍/Java

'프로그래밍 > Java' 카테고리의 다른 글

StringBuilder와 StringBuffer 차이  (0) 2013.12.16
스레드 풀 활용  (0) 2013.10.31
Comparator & Comparable 이용한 정렬  (0) 2013.05.20
java.util.ConcurrentModificationException  (1) 2013.05.15
업캐스팅  (0) 2011.09.27
posted by 암초보
2013. 10. 23. 14:30 DB/MySQL

http://jan.kneschke.de/projects/mysql/groupwise-max/


아래와 같은 방법도 있다...


SELECT continent,
       SUBSTRING( MAX( CONCAT(LPAD(population,10,'0'),name) ), 10+1) AS name,
       MAX( population ) AS population
  FROM Country
 GROUP BY continent;


SELECT continent,
       SUBSTRING_INDEX(GROUP_CONCAT(name ORDER BY population, ','), ',', 1)) AS name,
       MAX( population ) AS population
  FROM Country
 GROUP BY continent;


'DB > MySQL' 카테고리의 다른 글

INSERT IGNORE  (0) 2013.11.29
procedure function 덤프  (0) 2013.10.31
datadir 변경에 대한 답변  (0) 2013.09.25
SELECT 결과 INSERT하기  (0) 2013.09.12
last_insert_id()  (0) 2013.09.11
posted by 암초보
2013. 10. 22. 13:59 프로그래밍/기타

'프로그래밍 > 기타' 카테고리의 다른 글

git push 실패시..  (0) 2014.06.16
깔끔한 git 설명  (0) 2014.05.29
로딩 이미지 생성 페이지  (0) 2013.06.26
정규표현식 관련 정보  (0) 2012.02.09
Joda Time 라이브러리  (0) 2011.10.17
posted by 암초보
2013. 9. 25. 19:11 DB/MySQL

If you are using ubuntu or apparmor you should permit this change in apparmor.

Edit /etc/apparmor.d/usr.sbin.mysqld and change /var/lib/mysql with the new DATADIR.

It should work.

'DB > MySQL' 카테고리의 다른 글

procedure function 덤프  (0) 2013.10.31
The Rows Holding the Group-wise Maximum of a Certain Column  (0) 2013.10.23
SELECT 결과 INSERT하기  (0) 2013.09.12
last_insert_id()  (0) 2013.09.11
INDEX  (0) 2013.08.23
posted by 암초보
2013. 9. 12. 10:43 DB/MySQL

INSERT INTO target_table SELECT * FROM ori_table

간단함.

물론  insert의 필드와 select문의 필드를 맞춰야함.

'DB > MySQL' 카테고리의 다른 글

The Rows Holding the Group-wise Maximum of a Certain Column  (0) 2013.10.23
datadir 변경에 대한 답변  (0) 2013.09.25
last_insert_id()  (0) 2013.09.11
INDEX  (0) 2013.08.23
group_concat size  (0) 2013.06.04
posted by 암초보
2013. 9. 11. 15:40 DB/MySQL

last_insert_id()

자동 증가값을 가져오는 거지....

PK를 가져오는 것이아니다...


'DB > MySQL' 카테고리의 다른 글

datadir 변경에 대한 답변  (0) 2013.09.25
SELECT 결과 INSERT하기  (0) 2013.09.12
INDEX  (0) 2013.08.23
group_concat size  (0) 2013.06.04
char와 varchar 차이점  (0) 2011.10.31
posted by 암초보