Skip to main content

8. DATATYPES


A datatype defines which kind of values a column can contain.

Data type
Description

CHARACTER(n)
Character string. Fixed-length n
VARCHAR(n) or
CHARACTER VARYING(n)
Character string. Variable

Length. Maximum length n
BINARY(n)
Binary string. Fixed-length n
BOOLEAN
Stores TRUE or FALSE values
VARBINARY(n) or
BINARY VARYING(n)
Binary string. Variable length. Max length n
INTEGER(p)
Integer numerical (no decimal). Precision p
SMALLINT
Integer numerical (no decimal). Precision 5
INTEGER
Integer numerical (no decimal). Precision 10
BIGINT
Integer numerical (no decimal). Precision 19
DECIMAL(p,s)
Exact numerical, precision p, scale s.
NUMERIC(p,s)
Exact numerical, precision p, scale s. (Same as DECIMAL)
FLOAT(p)
Approximate numerical, mantissa precision p. A floating number in base 10 exponential notation. The size argument for this type consists of a single number specifying the minimum precision
REAL
Approximate numerical, mantissa precision 7
FLOAT
Approximate numerical, mantissa precision 16
DOUBLE PRECISION
Approximate numerical, mantissa precision 16
DATE
Stores year, month, and day values
TIME
Stores hour, minute, and second values
TIMESTAMP
Stores year, month, day, hour, minute, and second values
INTERVAL
Composed of a number of integer fields, representing a period of time, depending on the type of interval
ARRAY
A set-length and ordered collection of elements
MULTISET
A variable-length and unordered collection of elements
XML
Stores XML data












<<Prev                                                                                    Next>>









Comments

Popular posts from this blog

INDEX

                                                                                   INDEX      No.     Article                                                                       1.     Introduction of SQL           2.     Table Basic           3.     Keys and Constraints           4.     Referential integrity           5.     INDEX           6.     VIEW         ...

14. Ordering Results

ORDER BY used to sort the result-set by one or more columns. It Sorts the records in ascending order by default. To sort the records in a descending order, you can use the DESC keyword. SELECT column_name , column_name FROM table_name ORDERBY column_name ASC | DESC , column_name ASC | DESC ; SELECT * FROM Customers ORDERBY Country DESC ;      <<Prev                                                                                      Next>>

12. INSERT UPDATE and DELETE Queries

INSERT The INSERT INTO statement is used to insert new records in a table INSERTINTO table_name VALUES ( value1 , value2 , value3 ,...); Or INSERTINTO table_name ( column1 , column2 , column3 ,...) VALUES ( value1 , value2 , value3 ,...); UPDATE Used to update existing records in a table. UPDATE table_name SET column1 = value1 , column2 = value2 ,... WHERE some_column = some_value ; DELETE Used to delete rows in a table. DELETEFROM table_name WHERE some_column = some_value ; <<Prev                                                                           Next>>