diff --git a/episodes/00-sql-introduction.md b/episodes/00-sql-introduction.md index d8092898..53cdcadf 100644 --- a/episodes/00-sql-introduction.md +++ b/episodes/00-sql-introduction.md @@ -235,46 +235,16 @@ You can also use this same approach to append new fields to an existing table. ### Data types {#datatypes} -| Data type | Description | -| ----------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | -| CHARACTER(n) | Character string. Fixed-length n | -| VARCHAR(n) or CHARACTER VARYING(n) | Character string. Variable length. Maximum length n | -| BINARY(n) | Binary string. Fixed-length n | -| BOOLEAN | Stores TRUE or FALSE values | -| VARBINARY(n) or BINARY VARYING(n) | Binary string. Variable length. Maximum length n | -| INTEGER(p) | Integer numerical (no decimal). | -| SMALLINT | Integer numerical (no decimal). | -| INTEGER | Integer numerical (no decimal). | -| BIGINT | Integer numerical (no decimal). | -| DECIMAL(p,s) | Exact numerical, precision p, scale s. | -| NUMERIC(p,s) | Exact numerical, precision p, scale s. (Same as DECIMAL) | -| FLOAT(p) | Approximate numerical, mantissa precision p. A floating number in base 10 exponential notation. | -| REAL | Approximate numerical | -| FLOAT | Approximate numerical | -| DOUBLE PRECISION | Approximate numerical | -| DATE | Stores year, month, and day values | -| TIME | Stores hour, minute, and second values | -| TIMESTAMP | Stores year, month, day, hour, minute, and second values | -| INTERVAL | Composed of a number of integer fields, representing a period of time, depending on the type of interval | -| ARRAY | A set-length and ordered collection of elements | -| MULTISET | A variable-length and unordered collection of elements | -| XML | Stores XML data | - -### SQL Data Type Quick Reference {#datatypediffs} - -Different databases offer different choices for the data type definition. - -The following table shows some of the common names of data types between the various database platforms: - -| Data type | Access | SQLServer | Oracle | MySQL | PostgreSQL | -| :---------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | :--------------- | :------------ | :------------ | -| boolean | Yes/No | Bit | Byte | N/A | Boolean | -| integer | Number (integer) | Int | Number | Int / Integer | Int / Integer | -| float | Number (single) | Float / Real | Number | Float | Numeric | -| currency | Currency | Money | N/A | N/A | Money | -| string (fixed) | N/A | Char | Char | Char | Char | -| string (variable) | Text (\<256) / Memo (65k+) | Varchar | Varchar2 | Varchar | Varchar | -| binary object OLE Object Memo Binary (fixed up to 8K) | Varbinary (\<8K) | Image (\<2GB) Long | Raw Blob | Text Binary | Varbinary | +SQLite has four data types, shown in the table below. + +| Data type | Description | +| ----------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- | +| TEXT | Text string | +| INTEGER | Integer numerical (signed positive or negative) | +| REAL | Approximate numerical | +| BLOB | Multipurpose datatype with limited functionality that is generally used for data which does not fit into any of the other three categories | + +In addition to these four data types, SQLite has a NULL value for missing data. We will talk more about dealing with missing data in Episode 3. :::::::::::::::::::::::::::::::::::::::: keypoints diff --git a/learners/sql-cheat-sheet.md b/learners/sql-cheat-sheet.md index 91f48fa8..33b7ec93 100644 --- a/learners/sql-cheat-sheet.md +++ b/learners/sql-cheat-sheet.md @@ -41,6 +41,22 @@ Sort results using `ASC` for ascending order or `DESC` for descending order: SELECT * FROM table_name ORDER BY column_name_1 ASC, column_name_2 DESC; +Data Types +---------- + +Different databases offer different choices for the data type definition. + +The following table shows some of the common names of data types between the various database platforms: + +| Data type | Access | SQLServer | Oracle | MySQL | PostgreSQL | SQLite | +| :---------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | :--------------- | :------------ | :------------ | :------ | +| boolean | Yes/No | Bit | Byte | N/A | Boolean | Integer | +| integer | Number (integer) | Int | Number | Int / Integer | Int / Integer | Integer | +| float | Number (single) | Float / Real | Number | Float | Numeric | Real | +| currency | Currency | Money | N/A | N/A | Money | Real | +| string (fixed) | N/A | Char | Char | Char | Char | Text | +| string (variable) | Text (\<256) / Memo (65k+) | Varchar | Varchar2 | Varchar | Varchar | Text | +| binary object OLE Object Memo Binary (fixed up to 8K) | Varbinary (\<8K) | Image (\<2GB) Long | Raw Blob | Text Binary | Varbinary | Blob | Missing Data ------------