All for Joomla All for Webmasters

SQL Data Types

The SQL data type defines a kind of value that a column can contain.

In a database table, every column is required to have a name and a data type.

Data Type varies from database to database. For example, MySQL supports INT but Oracle supports NUMBER for integer values.

These are the general data types in SQL.

Data-type Syntax Explanation
Integer INTEGER integer number.
Smallint SMALLINT small integer number.
Numeric NUMERIC(P,S) where ‘p’ is precision value and ‘s’ is scale value.
Real REAL single precision floating point number
Decimal DECIMAL(P,S) where ‘p’ is precision value and ‘s’ is scale value.
Double precision DOUBLE PRECISION double precision floating point number
Float FLOAT(P) where ‘p’ is precision value
Character CHAR(X) where ‘x’ is the character’s number to store
Character varying VARCHAR2(X) where ‘x’ is the character’s number to store
Bit BIT(X) where ‘x’ is the number of bits to store
Bit varying BIT VARYING(X) ‘x’ is the number of bits to store (length can vary up to x)
Date DATE it stores year, month and days values.
Time TIME it stores hour, minute and second values
Timestamp TIMESTAMP it stores year, month, day, hour, minute and second values
Time with TIME WITH exactly same as time but also store an offset from UTC
time zone TIME ZONE of the time specified
timestamp with TIMESTAMP WITH same as timestamp but also stores an offset from UTC of
time zone TIME ZONE the time specified.
PinIt
submit to reddit

Leave a Reply

Top