In SQL, the data type is an attribute used to specify a type of data the column can hold, like numeric type, character type, binary type, date and time type, etc.
Generally, we will define a column datatype while creating a table, as shown below. In SQL, we have different ways to declare columns in the table like CREATE TABLE statement or directly creating a table in the database in SQL server management studio.
SQL Create Columns using Create Table Statement
CREATE TABLE SampleTable
(
UserId INT,
UserName VARCHAR(50),
Education VARCHAR(50),
Salary FLOAT
)
SQL Management Studio Create Columns in Table
In SQL, we have different types of data types available. Those are
- Exact Numeric Data Types (int, smallint, bigint, etc.)
- Approximate Numeric Data Types (float, real)
- Date and Time Data Types (date, datetime, time, smalldatetime, etc.)
- Character String Data Types (char, varchar, text, etc.)
- Unicode Character String Data Types (nchar, nvarchar, ntext)
- Binary Data Types
- Miscellaneous Data Types or Other Data Types