Skip to Content
SQLポケットガイド 第4版
book

SQLポケットガイド 第4版

by Alice Zhao, 原 隆文
July 2024
Intermediate to advanced
328 pages
3h 24m
Japanese
O'Reilly Japan, Inc.
Content preview from SQLポケットガイド 第4版

6章データ型

SQLのテーブルでは、それぞれの列は、1つのデータ型の値しか含むことができません。この章では、よく使われるデータ型について説明し、それらをどのような場合に、どのように使うべきかについて解説します。

次の文は3つの列を作成し、それぞれの列についてデータ型を指定しています。id列は整数の値を保持し、name列は最大で30文字の値を保持し、dt列は日付の値を保持します。

CREATE TABLE my_table (
   id INT,
   name VARCHAR(30),
   dt DATE
);

INT、VARCHAR、DATEは、SQLでの数多くのデータ型の一部にすぎません。表6-1に、データ型の4つのカテゴリーと一般的なサブカテゴリーを示します。データ型の構文はRDBMSによって大きく異なるので、この章のそれぞれのセクションで、それらの違いについて詳しく説明します。

表6-2に示したのは、それぞれのデータ型の値の例であり、それらの値がSQLでどのように表現されるかを示しています。これらの値は、しばしばリテラル(literal)または定数(constant)と呼ばれます。

表6-2 SQLでのリテラル

カテゴリーサブカテゴリー値の例
数値整数  小数  浮動小数点数123+123-123123.45+123.45-123.45123.45E+23 ...
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

Pythonクイックリファレンス 第4版

Pythonクイックリファレンス 第4版

Alex Martelli, Anna Martelli Ravenscroft, Steve Holden, Paul McGuire, 鈴木 駿, 株式会社クイープ
推薦システム実践入門 ―仕事で使える導入ガイド

推薦システム実践入門 ―仕事で使える導入ガイド

風間 正弘, 飯塚 洸二郎, 松村 優也

Publisher Resources

ISBN: 9784814400805Publisher Website