Member-only story

Data Handling in SQL: Exploring 14 Common Data Types

btd
3 min readDec 27, 2023

--

SQL (Structured Query Language) supports a variety of data types that define the type of data that a column can store in a relational database. Here’s an overview of common SQL data types:

I. Numeric Data Types:

1. INT (INTEGER):

Integer data type for whole numbers.

CREATE TABLE ExampleTable (
ID INT
);

2. FLOAT(p):

Floating-point number with a specified precision.

CREATE TABLE ExampleTable (
Price FLOAT(2)
);

3. DECIMAL(p, s):

Exact numeric, with a specified precision (total digits) and scale (decimal places).

CREATE TABLE ExampleTable (
Amount DECIMAL(8, 2)
);

II. Character String Data Types:

1. CHAR(n):

Fixed-length character string.

CREATE TABLE ExampleTable (
Initial CHAR(1)
);

2. VARCHAR(n):

Variable-length character string.

CREATE TABLE ExampleTable (
Name VARCHAR(50)
);

3. TEXT:

--

--

btd
btd

No responses yet