SQL > Data Definition Language (DDL) >
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:
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.
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.
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.
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 View
Learn From Udemy: Learn SQL Using PostgreSQL: From Zero to Hero
Copyright © 2021 1keydata.com All Rights Reserved