MariaDB) 문자열

Dec 05, 2023
MariaDB) 문자열
Contents
문자열

문자열

SELECT BIT_LENGTH (''); -- 할당된 bit 수
SELECT CHAR_LENGTH (''); -- 할당된 bit 수
SELECT LENGTH (''); -- 할당된 bit 수
영어와 한글의 할당되는 data가 다름
abc일 때)
notion image
notion image
notion image
a 한개일 때)
notion image
notion image
notion image
한글 1개일 때)
notion image
notion image
notion image
  • * CONCAT('나열',,,); : 잇다
나열된 문자열들을 이어붙여 하나의 문자열로 만들어줌
notion image
notion image
  • * CONCAT_WS('옵션', '나열',,,); 옵션 추가하여 나열
notion image
notion image
  • * SELECT ELT(몇번째, 'a', 'b', 'c'); : 첫번째 인수가 나열된 문자열 중에 몇번째인지 나타내줌
범위를 벗어나면 NULL
notion image
notion image
  • * SELECT FIELD('찾고자하는 문자', 'a', 'b', 'c');
: 나열된 문자열 중에서 찾고자하는 문자열이 몇번째에 있는지 알려줌
notion image
  • * SELECT FIND_IN_SET('bc', 'a, bc, c'); : 일치하는 문자열이 있는지 확인
없으면 0
notion image
notion image
  • * SELECT LOCATE('찾을 문자', '문자열'); : 문자열 하나에서 찾고자 하는 문자가 있으면 위치를 알려줌
notion image
notion image
  • * SELECT INSTR('문자열', '찾을 문자'); : 문자열 하나에서 찾고자 하는 문자가 있으면 위치를 알려줌
LOCATE와 같으나 찾을 문자와 문자열 입력 순서가 다름
notion image
notion image
  • * SELECT FORMAT(123456.123456, 4); : 소수점 자리수를 지정
천자리 마다 ','로 구분
반올림
notion image
notion image
notion image
반올림
  • * SELECT BIN(); : 10진수를 2진수로 바꿔줌
notion image
notion image
notion image
notion image
  • * SELECT OCT(); : 10진수를 8진수로 바꿔줌
notion image
notion image
notion image
  • * SELECT HEX(); : 10진수를 16진수로 바꿔줌
notion image
notion image
notion image
  • * SELECT INSERT('abcdefghi', 3, 4, '@@@@');
: 문자열이 주어지면 주어진 문자열에 추가할 문자열을 추가할것인데 몇번째의 몇개를 지우고 추가
notion image
notion image
notion image
  • * SELECT LEFT('문자열', 순서); : 왼쪽에서부터 몇번째 글자를 반환
notion image
  • * SELECT RIGHT('문자열', 순서); : 오른쪽에서부터 몇번째 글자를 반환
notion image
가운데 위치한 글자 반환
  • * SELECT RIGHT((SELECT LEFT('문자열', 순서)), 순서);
  • * SELECT MID('문자열', 순서);
  • * SELECT SUBSTRING('문자열', 순서);
  • * SELECT SUBSTRING('문자열', 순서);
notion image
  • * SELECT CONCAT('문자열', SPACE(숫자), '문자열'); : 문자열 사이에 SPACE 공간이 생김
notion image
notion image
  • * SELECT REVERSE('문자열'); : 문자 역순으로 반환
notion image
  • * SELECT REPLACE('문자열', ' 바꿀 문자', '바뀐 문자'); : 일정 부분을 바꿔줌
notion image
  • * SELECT TRIM(' 문자열 '); : 앞뒤로 공백 제거
notion image
notion image
  • * SELECT LTRIM(' 문자열'); : 왼쪽에 있는 공백 제거
notion image
  • * SELECT RTRIM('문자열 '); : 오른쪽에 있는 공백 제거
notion image
SELECT repeat('abc', 3); : 주어진 문자열을 몇번 반복
notion image
Share article
RSSPowered by inblog