SQL Data Types – Tutorialpath


SQL Data Types

SQL Data Types define the type of value that can be stored in a table column.

A data type is a set of representable values. Every representable value belongs to at least one data type and some belong to several data types.

SQL supports three sorts of data types:

  1. predefined data types
  2. constructed types
  3. user-defined types

Predefined data types are sometimes called the “built-in data types”, though not in this International Standard. Every predefined data type is a subtype of itself and of no other data types. It follows that every predefined data type is a supertype of itself and of no other data types.

User-defined data types can be defined by a standard, by an implementation, or by an application.

A constructed type is specified using one of SQL’s data type constructors, ARRAY, REF, and ROW. The type is either an array type, a reference type or a row type, according to whether it is specified with ARRAY, REF, or ROW, respectively. Array types are the only examples of constructed types known generically as collection types.

SQL data types can be broadly divided into following categories.

  1. Numeric data types such as int, tiny int, bigint, float, real etc.
  2. Date and Time data types such as Date, Time, Date time etc.
  3. Character and String data types such as char, varchar, text etc.
  4. Unicode character string data types, for example nchar, nvarchar, ntext etc.
  5. Binary data types such as binary, varbinary etc.
  6. Miscellaneous data types – clob, blob, xml, cursor, table etc.

SQL Server offers six categories of data types for your use which are listed below −

Exact Numeric Data Types

Approximate Numeric Data Types

Date and Time Data Types

datetime has 3.33 milliseconds accuracy where as small datetime has 1 minute accuracy.

Character Strings Data Types

char string data types
char string data types

Unicode Character Strings Data Types

unicode string data types
unicode string data types

Binary Data Types

binary data types
binary data types

Misc Data Types

misc data types
misc data types

People also ask

  1. What is SQL type?

-> SQL Data Types define the type of value that can be stored in a table column.

2. Is date a data type in SQL?

-> SQL Date Data Types. MySQL comes with the following data types for storing a date or a date/time value in the database: DATE – format YYYY-MM-DD. … TIMESTAMP – format: YYYY-MM-DD HH:MI:SS.

3. How many types of SQL Server are there?

-> SQL Server supports three different types of replication.


Leave a Reply

Your email address will not be published. Required fields are marked *