Skip to main content

Data Types In SQL

 

Data Types In SQL

What is Data Type?

A data type as the name suggests it is the type or category to which the data belongs to. A data type specifies a particular type of data, such as integer, floating-point, Boolean, etc. In SQL, the data type defines the type of data to be stored in each column of a table.

SQL data types can be broadly divided into three categories

1.      Numeric Data Types

2.      String Data Types

3.      Data & Time Data Types

Numeric Data Types

String Data Types

Data&Time DataTypes

BIT

CHAR(SIZE)

DATE

TINYINT

VARCHAR(SIZE)

TIME

SMALLINT

TEXT(SIZE)

DATETIME

MEDIUMINT

TINYTEXT(SIZE)

TIMESTAMP

INT

MEDIUMTEXT(SIZE)

YEAR

BIGINT

LONGTEXT

 

FLOAT

BINARY

 

DOUBLE

ENUM

 

BOOLEAN

SET

 

 

Most commonly used data types

1.   INT :  The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

2.   CHAR Or VARCHAR : The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to store. For example, CHAR(30) can hold up to 30 characters.

3.   DATE & TIME Data Types:

a)   DATE : Stores date in the format of YYY-MM-DD.

b)  TIME : Stores time in the format of HH:MI:SS.

c)    DATATIME : Stores date and time information in the format of    YYYY-MM-DD HH:MI:SS.

d)  TIMESTAMP : Stores number of second passed science the Unix epoch (‘1970-01-01 00:00:00’ UTC).

YEAR : MySQL displays YEAR values in YYYY format, with a range of 1901 to 2155, and 0000.

 

                                                                                                                 

Comments

Popular posts from this blog

Methods of String in java

  String in Java String:   A Java string is  a sequence of characters that exist as an object of the class java. lang. Here is  the list of important methods available in the java string class: Ø  startsWith ( ): It checks if the string starts with the given prefix. If yes then return true else false. Ø  endsWith () : It checks if the string ends with the given suffix. If yes then return true else false. Ø  substring(int begin index) : It return s  the substring of the string. The substring start s  with the character at the specified index. Ø   substring(Int begin index , int end index) : Returns the substring. The substring starts with the character at begin index and ends with the character at end index. Ø  toLowerCase() : It converts all  the character s  of the string into lower case(Small Letters).   Ø  toUpperCase() : It converts all the character s  of the string into upper case(Capital Let...

Variables and Data types in Java

  MY PROGRAMMING PARADISE Variables: Variables are used to store data in a computer’s memory. In other words, we can say, variables are just like a container that holds the value while the java program executed. There are three types of variables in java: 1-  Local 2-  Instance 3-  Static   Rules for declaring identifier (Variable name) 1-  All identifiers must begin with a letter, currency character, or underscore. 2-  Blank spaces are not allowed. 3-  An identifier name is case-sensitive. 4-  A keyword cannot be used as an identifier.   Declaring variables: byte age = 28; short salary =32500; float price = 25.50f; char name = ‘v’; boolean flag=true;   Data types: There are two types of data types in java. 1-  Primitive Data type 2-  Non- primitive Data types   Primitive Data type: There are mainly eight types of primitive data types: Types Size Range Default Value byte 1 Byte [-128, 127] 0 short 2 Byte [-32,768 , 32...

Switch Statement In Java

Switch Statement:  The switch statement is just like if-else-if ladder statement. It executes one statement from multiple conditions. It works with a byte, short, int, long, and String. In other words, we can say the Switch case statement is a substitute for a long if statement that compares to several integral values. Syntax of Switch statement in java Enhance Switch or Switch With Arrow: The new syntax uses the -> operator instead of the colon we're used to with switch statements. Also, there's no break keyword. Another addition is the fact that we can now have comma-delimited criteria. Syntax of Enhance Switch in java