SQL Data Types

There are various types of data available for the letters in the alphabet, such as the character data type, or the Boolean data type for true or false values.

What Is SQL Data Types?

Within SQL, data type essentially determines the type of data that will go into a particular column. All entries of a specific column shall be of the same form of data.

Find the workplace base pay list. Let us take, for example, the e salary column. The first value in this column is of an integer type; the second is also of the integer type, and likewise all other e salary column entries are of integer type. Now consider another e dept column from the same table, all values entered in this column are of the type of character.

SQL Data Types

Those types of data contain weaknesses and credibility. The limitations on the data are constraints. They can be deployed either to a column or to a table. If a violation occurs between the data action and the constraint, then the action will be aborted. There are different types of constraints including primary key, special key, etc.

Different Data Types in SQL

Types of SQL data are divided into three main categories, namely numeric, character, date and time.

Numeric Data Types in SQL

Numeric types of data store any number values or integer values.

Numeric Data Types in SQL
  • Bigint type of data helps to store the ‘very big’ values.
  • Data type Int is used to store fairly large values.
  • The Smallint type of data is used to store values ranging from −32,768 to 32,767.
  • Data type Tinyint stores values between 0 and 255. It is for comparatively small numbers.
  • Decimal data form is used in two statements to store the fractional values. The first part is the size of the value that is the total number of digits, and after the decimal point the second part specifies the number of digits (d). Let ‘s assume, we want the decimal value to be stored at 12.50

Any type of data may be used according to the requirement. The most widely used type of data is Int.

Character Data Types in SQL

All alphabetic values and special characters are contained in character data types.

Character Data Types in SQL
  • Char data form has fixed length and takes only one argument. Consider the value scale, for instance, as 20. This would mean you can’t offer more than 20 characters worth of any value. Keep in mind that char has a fixed length, i.e. if the size of the value is 30 characters, but the information allocated is 3 characters, then the memory consumed is 30 characters.
  • The form of data in Varchar often takes size as the argument. But here, unlike char, it is a type of data with variable length. So here if the size of the value is to be 30 characters, and you only give 3 characters, the memory consumed will only be 3 characters.
  • A string with a maximum length of 65,535 characters will take the form of text data.

Date and Time Data Types in SQL

Date and Time data types store a date or a date/time value.

Date and Time Data Types in SQL
  • Date style data in SQL allows us to define the date in a format. Let’s say, if we want the date to be stored, 2 January 2019, then we will first give the year that would be 2 0 1 9, then the month that would be 0 1, and finally, the day that would be 0 2.
  • The type of time data allows us to determine the time depicted in a format. Let’s say, we want 8:30:23 a.m. time to be stored So we’ll decide first the hour that would be 0 8, then the minutes that would be 3 0, and finally the seconds that would be 2 3.
  • Year type of data holds year values like 1995 or 2011

Leave a Reply