Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Structured Query Language(SQL) as we all know is the database language by the use

of which we can perform certain operations on the existing database and also we can
use this language to create a database. SQL uses certain commands like Create, Drop,
Insert etc. to carry out the required tasks.
These SQL commands are mainly categorized into four categories as discussed below:
1. DDL(Data Definition Language) : DDL or Data Definition Language actually
consists of the SQL commands that can be used to define the database schema. It
simply deals with descriptions of the database schema and is used to create and
modify the structure of database objects in database.
Examples of DDL commands:
 CREATE – is used to create the database or its objects (like table, index,
function, views, store procedure and triggers).
 DROP – is used to delete objects from the database.
 ALTER-is used to alter the structure of the database.
 TRUNCATE–is used to remove all records from a table, including all spaces
allocated for the records are removed.
 COMMENT –is used to add comments to the data dictionary.
 RENAME –is used to rename an object existing in the database.

SQL General Data Types


Each column in a database table is required to have a name and a data type.

SQL developers have to decide what types of data will be stored inside each and
every table column when creating a SQL table. The data type is a label and a
guideline for SQL to understand what type of data is expected inside of each
column, and it also identifies how SQL will interact with the stored data.

The following table lists the general data types in SQL:

Data type Description

CHARACTER(n) Character string. Fixed-length n

VARCHAR(n) or Character string. Variable length. Maximum length n


CHARACTER VARYING(n)
BINARY(n) Binary string. Fixed-length n

BOOLEAN Stores TRUE or FALSE values

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. Example: decimal(5,2) is


before the decimal and 2 digits after the decimal

NUMERIC(p,s) Exact numerical, precision p, scale s. (Same as DECIMAL)

FLOAT(p) Approximate numerical, mantissa precision p. A floating numb


notation. The size argument for this type consists of a single n
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

You might also like