The Different Data Types in SQL - SQL Bootcamp: Learn the Basics of SQL Programming in 2 Weeks (2016)

SQL Bootcamp: Learn the Basics of SQL Programming in 2 Weeks (2016)

Chapter 4. The Different Data Types in SQL

In the SQL language, data type is a characteristic that determines the type of any database object. All columns, variables, and expressions involve data types in SQL.

You should indicate data types while generating new tables. Additionally, you have to select data types for your tables based on your needs.

This computer language supports many types of data. Let’s divide these types into six major categories:

1. Exact Numeric

2. Approximate Numeric

3. Time and Date

4. Character Strings – This is divided into two subcategories:

1. Unicode Strings

2. Non-Unicode Strings

5. Binary

6. Miscellaneous

This category involves the following data types:

· timestamp– This data type stores a unique number that becomes updated whenever a row becomes updated. You may access this unique number in any part of your database.

· xml– This data type stores XML (i.e. Extensible Markup Language) information. You may save XML data in columns or variables.

· table– This type saves the results of your database queries so that you can use them in the future.

· cursor– This data type allows you to make references to any cursor object in your database.

· sql_variant– This can store the values of all SQL-compatible data types, except timestamp, text, and next.

· unique identifier– This data type can store GUIDs (i.e. Globally Unique Identifiers).