SQL Data Types



  SQL > Table Manipulation > Create Table Statement

In the CREATE TABLE page, we mentioned that it is necessary to specify the data type for each column when we create a table. So exactly what are the different types of data we can store in a table? While it is beyond the scope of this tutorial to list the exact data types supported by all the major database tools, we can nevertheless group the different data types into the following categories:

  • Numeric
  • Character String
  • Date/Datetime
  • Binary

    Numeric

    This type of data stores numerical values. Data types that fall in this category include Integer, Float, Real, Numeric, or Decimal. Common functions that operate on this type of data include COUNT, SUM, MAX, MIN, and AVG.

    Character String

    This type of data stores character values. The two common types are CHAR(n) and VARCHAR(n). The CHAR(n) data type holds n characters, padded with spaces at the end if needed. VARCHAR stands for Varying Char, meaning that the length of the field can vary. For example, a VARCHAR(10) data type holds up to 10 characters. But if data is only 8 characters long, then it will only store 8 characters. Common functions that operate on this type of data are discussed in String Functions.

    Binary

    This type of data allows us to store binary objects in a database table. Data types that fall in this category include Blob, Binary, and Raw. Please note that a field of binary data type cannot be used as keys, and one cannot build a table index using a binary column.

    Date/Datetime

    This type of data allows us to store date or datetime in a database table. Different databases have very different implementations of the date / datetime data type. Common functions that operate on this type of data are discussed in Date Functions.

    Next: SQL CONSTRAINT




    Copyright © 2013 1keydata.com   All Rights Reserved.     Privacy Policy


  • SQL SELECT
    SQL DISTINCT
    SQL WHERE
    SQL AND OR
    SQL IN
    SQL BETWEEN
    SQL Wildcard
    SQL LIKE
    SQL ORDER BY
    SQL Functions
    SQL Average
    SQL COUNT
    SQL MAX
    SQL MIN
    SQL SUM
    SQL GROUP BY
    SQL HAVING
    SQL ALIAS
    SQL AS
    SQL JOIN
    SQL INNER JOIN
    SQL OUTER JOIN
    SQL LEFT OUTER JOIN
    SQL CROSS JOIN
    SQL SELECT UNIQUE
    SQL ROUND
    SQL CAST
    SQL CONVERT
    SQL CONCATENATE
    SQL SUBSTRING
    SQL INSTR
    SQL TRIM
    SQL LENGTH
    SQL REPLACE
    SQL DATEADD
    SQL DATEDIFF
    SQL DATEPART
    SQL GETDATE
    SQL SYSDATE

    SQL CREATE TABLE
    SQL Data Types
    SQL CONSTRAINT
    SQL NOT NULL
    SQL DEFAULT
    SQL UNIQUE
    SQL CHECK
    PRIMARY KEY
    FOREIGN KEY
    SQL View
    SQL CREATE VIEW
    SQL Index
    SQL CREATE INDEX
    SQL ALTER TABLE
    SQL DROP TABLE
    SQL TRUNCATE TABLE
    SQL USE
    SQL CREATE DATABASE
    SQL DROP DATABASE
    SQL INSERT INTO
    SQL INSERT INTO SELECT
    SQL UPDATE
    SQL DELETE FROM

    SQL Video Tutorial
    SQL Jobs

    Site Map
    Resources