SQL provides different data types for storing data and they are classified into various categories. Let us have a look at the different categories of data types –
- Exact Numeric – These data types are using to store numeric data.
- Approximate Numeric – These are also used to store numeric data but with less precision.
- Date and Time – These are used to store the date and time.
- Character String – These are used to store string data.
- Unicode Character String – These are used to store Unicode data.
- Binary String– This is used to store binary data
- Others – They are used to store other kinds of data such as XML, time stamp etc.
- To store fixed size alphanumeric or character values, CHAR data type is used.
- To store variable size alphanumeric or character values, VARCHAR data type can be used.
- For storing small numeric values, TINY INT data type can be used. It can store values ranging from 0 to 255, both inclusive.
- When we need to store data and we don’t know the range, INT or numeric is preferred. Now, if you want that the number should always be a four digit, this cannot be done using INT, so we do it using NUMERIC (4).
- When we need to store only the date, DATE data type is used.
- For storing monetary values, we have two data types, MONEY and SMALL MONEY. They are used depending on the range. SMALLMONEY can store from – -2147438.3648 to 214748.3647. MONEY can store from – 922337203685477.5808 to 922337203685.477.5807.
OTHER IMPORTANT DATA TYPES
nCHAR, nVARCHAR, nTEXT à These data types are used to store data of different languages.
TIME- This data type is used to store time
TIMESTAMP – It is used to automatically generate binary numbers, which are guaranteed to be unique.
XML- XML is used to store XML data.
Happy Learning 🙂

Leave a comment