블로그 이미지
암초보

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-06 02:36
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. 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 암초보
2013. 8. 23. 10:11 DB/MySQL

SHOW INDEX FROM 테이블명;

SHOW KEYS FROM 테이블명;



CREATE INDEX 인덱스명 ON 테이블명(컬럼명);


DROP INDEX 인덱스명 ON 테이블명

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

SELECT 결과 INSERT하기  (0) 2013.09.12
last_insert_id()  (0) 2013.09.11
group_concat size  (0) 2013.06.04
char와 varchar 차이점  (0) 2011.10.31
MySQL function 생성 실패시  (0) 2011.10.06
posted by 암초보
2013. 6. 4. 10:08 DB/MySQL

group_concat_max_len 을 변경하면 된다.

커맨드로는

SET GLOBAL group_concat_max_len=#size#

SET SESSION group_concat_max_len=#size#

재시작 할 필요없고, 재시작하면 기본설정으로 초기화된다.




my.cnf의

[mysqld] 밑에...

group_concat_max_len=8K 

이런식으로 넣어주면 된다. 물론 재시작 해야함.

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

last_insert_id()  (0) 2013.09.11
INDEX  (0) 2013.08.23
char와 varchar 차이점  (0) 2011.10.31
MySQL function 생성 실패시  (0) 2011.10.06
컬럼 추가, 컬럼명 변경  (0) 2011.09.24
posted by 암초보
2012. 1. 3. 22:24 DB/Oracle

ANSI SQL
SELECT T1.A,T1.B,T2.C
FROM T1 INNER JOIN T2 ON T1.A=T2.A (ON 다음에서 기본키와 외래키 비교)

T-SQL
SELECT T1.A,T1.B, T2.C
FROM T1 , T2
WHERE T1.A = T2.A (WHERE절에서 기본키와 외래키 비교)

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

Oracle의 IndexOf 비슷한것!!  (0) 2011.08.09
DECODE  (0) 2010.12.28
오라클 view 정보 조회  (0) 2010.12.27
오라클 버전 확인 쿼리  (0) 2010.09.17
posted by 암초보
2011. 10. 31. 22:50 DB/MySQL

char는 고정길이
varchar는 가변길이(길이(length)를 저장하기위해 1byte 를 더 차지함)

ex) char(5) 에 'ab' 입력시, 'ab   ' 으로 저장됨.(5byte)
     varchar(5)에 'ab' 입력시, 'ab' 으로 저장됨.(3byte)


입력되는 길이가 고정되어 있다면 char 사용하는것이 좋을 듯.

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

INDEX  (0) 2013.08.23
group_concat size  (0) 2013.06.04
MySQL function 생성 실패시  (0) 2011.10.06
컬럼 추가, 컬럼명 변경  (0) 2011.09.24
MySQL 다운로드  (0) 2011.09.19
posted by 암초보
2011. 10. 6. 22:48 DB/MySQL

ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL,
or READS SQL DATA in its declaration and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_function_creators
variable)




show global variables like 'log_bin_trust_function_creators';

off 일경우

SET GLOBAL log_bin_trust_function_creators = 'ON';

또는
SET GLOBAL log_bin_trust_function_creators = 1;

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

group_concat size  (0) 2013.06.04
char와 varchar 차이점  (0) 2011.10.31
컬럼 추가, 컬럼명 변경  (0) 2011.09.24
MySQL 다운로드  (0) 2011.09.19
MySQL 버전 확인  (0) 2010.11.24
posted by 암초보
2011. 9. 24. 22:29 DB/MySQL

alter table 테이블명 add (컬럼명 자료형, ...);
alter table 테이블명 change old컬럼명 new컬럼명 자료형;

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

char와 varchar 차이점  (0) 2011.10.31
MySQL function 생성 실패시  (0) 2011.10.06
MySQL 다운로드  (0) 2011.09.19
MySQL 버전 확인  (0) 2010.11.24
MySQL 문자셋 변경  (0) 2009.12.17
posted by 암초보
prev 1 2 3 4 next