RPAD()
RPAD() 함수는 문자열을 특정 길이까지 다른 문자열로 오른쪽 부분을 채운다.
MySQL 4.0부터 작동한다.
형식
RPAD(string, length, rpad_string)
매개변수
string
:
원래 문자열의 길이가 length 매개 변수보다 클 경우 이 함수는 문자열에서 넘치는 문자를 제거한다.
length
:
문자열을 오른쪽으로 추가한 후의 길이
rpad_string
:
문자열에서 오른쪽을 채울 문자열
예제
총 길이가 20이 되도록 문자열을 “ABC”로 오른쪽을 채운다.
SELECT RPAD("SQL Tutorial", 20, "ABC");
기본 예시
RPAD(“SQL Tutorial”, 20, “ABC”) |
---|
SQL TutorialABCABCAB |
총 길이가 30이 되도록 “CustomerName”의 텍스트를 “ABC”로 오른쪽 부분을 채운다.
SELECT RPAD(CustomerName, 30, "ABC") AS RightPadCustomerName FROM Customers;
기본 예시
RightPadCustomerName |
---|
Alfreds FutterkisteABCABCABCAB |
Ana Trujillo Emparedados y hel |
Antonio Moreno TaqueríaABCABCA |
Around the HornABCABCABCABCABC |
Berglunds snabbköpABCABCABCABC |
Blauer See DelikatessenABCABCA |
Blondel père et filsABCABCABCA |
Bólido Comidas preparadasABCAB |
Bon app’ABCABCABCABCABCABCABCA |
Bottom-Dollar MarketseABCABCAB |
B’s BeveragesABCABCABCABCABCAB |
Cactus Comidas para llevarABCA |
Centro comercial MoctezumaABCA |
Chop-suey ChineseABCABCABCABCA |
Comércio MineiroABCABCABCABCAB |
Consolidated HoldingsABCABCABC |
Drachenblut DelikatessendABCAB |
Du monde entierABCABCABCABCABC |
Eastern ConnectionABCABCABCABC |
Ernst HandelABCABCABCABCABCABC |
Familia ArquibaldoABCABCABCABC |
FISSA Fabrica Inter. Salchicha |
Folies gourmandesABCABCABCABCA |
Folk och fä HBABCABCABCABCABCA |
FrankenversandABCABCABCABCABCA |
France restaurationABCABCABCAB |
Franchi S.p.A.ABCABCABCABCABCA |
Furia Bacalhau e Frutos do Mar |
Galería del gastrónomoABCABCAB |
Godos Cocina TípicaABCABCABCAB |
Gourmet LanchonetesABCABCABCAB |
Great Lakes Food MarketABCABCA |
GROSELLA-RestauranteABCABCABCA |
Hanari CarnesABCABCABCABCABCAB |
HILARIÓN-AbastosABCABCABCABCAB |
Hungry Coyote Import StoreABCA |
Hungry Owl All-Night GrocersAB |
Island TradingABCABCABCABCABCA |
Königlich EssenABCABCABCABCABC |
La corne d’abondanceABCABCABCA |
La maison d’AsieABCABCABCABCAB |
Laughing Bacchus Wine CellarsA |
Lazy K Kountry StoreABCABCABCA |
Lehmanns MarktstandABCABCABCAB |
Let’s Stop N ShopABCABCABCABCA |
LILA-SupermercadoABCABCABCABCA |
LINO-DelicatesesABCABCABCABCAB |
Lonesome Pine RestaurantABCABC |
Magazzini Alimentari RiunitiAB |
Maison DeweyABCABCABCABCABCABC |
Mère PaillardeABCABCABCABCABCA |
Morgenstern GesundkostABCABCAB |
North/SouthABCABCABCABCABCABCA |
Océano Atlántico Ltda.ABCABCAB |
Old World DelicatessenABCABCAB |
Ottilies KäseladenABCABCABCABC |
Paris spécialitésABCABCABCABCA |
Pericles Comidas clásicasABCAB |
Piccolo und mehrABCABCABCABCAB |
Princesa Isabel VinhossABCABCA |
Que DelíciaABCABCABCABCABCABCA |
Queen CozinhaABCABCABCABCABCAB |
QUICK-StopABCABCABCABCABCABCAB |
Rancho grandeABCABCABCABCABCAB |
Rattlesnake Canyon GroceryABCA |
Reggiani CaseificiABCABCABCABC |
Ricardo AdocicadosABCABCABCABC |
Richter SupermarktABCABCABCABC |
Romero y tomilloABCABCABCABCAB |
Santé GourmetABCABCABCABCABCAB |
Save-a-lot MarketsABCABCABCABC |
Seven Seas ImportsABCABCABCABC |
Simons bistroABCABCABCABCABCAB |
Spécialités du mondeABCABCABCA |
Split Rail Beer & AleABCAB |
Suprêmes délicesABCABCABCABCAB |
The Big CheeseABCABCABCABCABCA |
The Cracker BoxABCABCABCABCABC |
Toms SpezialitätenABCABCABCABC |
Tortuga RestauranteABCABCABCAB |
Tradição HipermercadosABCABCAB |
Trail’s Head Gourmet Provision |
VaffeljernetABCABCABCABCABCABC |
Victuailles en stockABCABCABCA |
Vins et alcools ChevalierABCAB |
Die Wandernde KuhABCABCABCABCA |
Wartian HerkkuABCABCABCABCABCA |
Wellington ImportadoraABCABCAB |
White Clover MarketsABCABCABCA |
Wilman KalaABCABCABCABCABCABCA |
WolskiABCABCABCABCABCABCABCABC |
참고
W3C School - MySQL RPAD() Function
W3C School - SQL Tutorial