Skip to Content
SQLクックブック 第2版 ―データベースエキスパート、データサイエンティストのための実践レシピ集
book

SQLクックブック 第2版 ―データベースエキスパート、データサイエンティストのための実践レシピ集

by Anthony Molinaro, Robert de Graaf, 嶋田 健志, 木下 哲也
February 2022
Intermediate to advanced
560 pages
8h 5m
Japanese
O'Reilly Japan, Inc.
Content preview from SQLクックブック 第2版 ―データベースエキスパート、データサイエンティストのための実践レシピ集

6章文字列

本章では、SQLにおける文字列操作を取り上げます。SQLは複雑な文字列操作を実行するようには設計されていないので、SQLで文字列を操作するのは面倒でイライラすることもあるでしょう。SQLには制限があるにもかかわらず、多くのRDBMSでは便利な組み込み関数が用意されているので、それらを工夫して使っていきます。特に本章は、「はじめに」で伝えようとした「SQLは良いものであり、悪いものであり、醜いものである」というメッセージを象徴するものです。本章を読み、SQLで文字列を扱う際にできることとできないことをよく理解してもらえればと思います。多くの場合、文字列のパースと変換がとても簡単なので驚くでしょう。一方ではある特定の処理を行うのに必要となるSQLの種類にうんざりすることもあるでしょう。

以降の多くのレシピでは、TRANCATE関数とREPLACE関数を使います。現在ではTRANCATE関数とREPLACE関数は本書で扱うすべてのRDBMSで使うことができますが、MySQLだけは例外で、REPLACEしかありません。しかしMySQLの場合には、ネストされたREPLACE関数を使ってTRANSLATEの効果を再現できることを指摘しておきます。

レシピ6.1はとても重要で、この後のいくつかの解決策で利用します。多くの場合、文字列の中を一度に1文字ずつトラバースする機能が欲しいでしょう。残念ながら、SQLでは簡単にはできません。文字列内をトラバースするには、SQLで提供されている限られたループ機能を使って文字を反復処理する必要があります。本書ではこの操作を「文字列の反復処理」と呼び、レシピ6.1でその手法を説明します。これはSQLの文字列パースの基本的な操作です。本章のほぼすべてのレシピで参照され使われています。この手法がどのように機能するかをしっかりと理解することを強くお勧めします。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

詳解 Rustアトミック操作とロック ―並行処理実装のための低レイヤプログラミング

詳解 Rustアトミック操作とロック ―並行処理実装のための低レイヤプログラミング

Mara Bos, 中田 秀基
戦略的データサイエンス入門 ―ビジネスに活かすコンセプトとテクニック

戦略的データサイエンス入門 ―ビジネスに活かすコンセプトとテクニック

Foster Provost, Tom Fawcett, 竹田 正和, 古畠 敦, 瀬戸山 雅人, 大木 嘉人, 藤野 賢祐, 宗定 洋平, 西谷 雅史, 砂子 一徳, 市川 正和, 佐藤 正士

Publisher Resources

ISBN: 9784873119779Other