Data Types

On Day 9, “Creating and Maintaining Tables,” we discussed data types. When creating tables in SQL, you must specify a specific data type for each column.

Note

Data types vary among implementations of SQL because of the way each database server stores data. For instance, Oracle uses certain data types, whereas Sybase and Microsoft's SQL Server have their own data types.

Sybase and Microsoft's SQL Server support the following data types.

Character Strings

  • char stores fixed-length character strings, such as a STATE abbreviation, where the column is always two characters.

  • varchar stores variable-length character strings, such as an individual's name, where the exact length of a name is not specified. For example, from AL RAY to WILLIAM ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.