May 25, 2012

SQL: Data Types

The following is a list of general SQL datatypes that may not be supported
by all relational databases.


|-----------+------------+--------------------------------------|
| Data Type | Syntax | Explanation (if applicable) |
|-----------+------------+--------------------------------------|
| integer | integer | |
|-----------+------------+--------------------------------------|
| smallint | smallint | |
|-----------+------------+--------------------------------------|
| numeric | numeric | Where p is a precision value; s is a |
| | (p,s) | scale value. For example, numeric |
| | | (6,2) is a number that has 4 digits |
| | | before the decimal and 2 digits after|
| | | the decimal. |
|-----------+------------+--------------------------------------|
| decimal | decimal | Where p is a precision value; s is a |
| | (p,s) | scale value. |
|-----------+------------+--------------------------------------|
| real | real | Single-precision floating point |
| | | number |
|-----------+------------+--------------------------------------|
| double | double | Double-precision floating point |
| precision | precision | number |
|-----------+------------+--------------------------------------|
| float | float(p) | Where p is a precision value. |
|-----------+------------+--------------------------------------|
| character | char(x) | Where x is the number of characters |
| | | to store. This data type is space |
| | | padded to fill the number of |
| | | characters specified. |
|-----------+------------+--------------------------------------|
| character | varchar2(x)| Where x is the number of characters |
| varying | | to store. This data type does NOT |
| | | space pad. |
|-----------+------------+--------------------------------------|
| bit | bit(x) | Where x is the number of bits to |
| | | store. |
|-----------+------------+--------------------------------------|
| bit | bit varying| Where x is the number of bits to |
| varying | (x) | store. The length can vary up to x. |
|-----------+------------+--------------------------------------|
| date | date | Stores year, month, and day values. |
|-----------+------------+--------------------------------------|
| time | time | Stores the hour, minute, and second |
| | | values. |
|-----------+------------+--------------------------------------|
| timestamp | timestamp | Stores year, month, day, hour, |
| | | minute, and second values. |
|-----------+------------+--------------------------------------|
| time with | time with | Exactly the same as time, but also |
| time zone | time zone | stores an offset from UTC of the time|
| | | specified. |
|-----------+------------+--------------------------------------|
| timestamp | timestamp | Exactly the same as timestamp, but |
| with time | with time | also stores an offset from UTC of the|
| zone | zone | time specified. |
|-----------+------------+--------------------------------------|
| year-month| | Contains a year value, a month value,|
| interval | | or both. |
|-----------+------------+--------------------------------------|
| day-time | | Contains a day value, an hour value, |
| interval | | a minute value, and/or a second |
| | | value. |
|-----------+------------+--------------------------------------|


1 comment:

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

My Favorite Site's List

#update below script more than 500 posts