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:
- predefined data types
- constructed types
- 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.
- Numeric data types such as int, tiny int, bigint, float, real etc.
- Date and Time data types such as Date, Time, Date time etc.
- Character and String data types such as char, varchar, text etc.
- Unicode character string data types, for example nchar, nvarchar, ntext etc.
- Binary data types such as binary, varbinary etc.
- 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
Unicode Character Strings Data Types
Binary Data Types
Misc Data Types
People also ask
- 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.