Introduction to SQL | Structured Query Language


What is SQL?

Full form of SQL is Structured Query Language, that could be a language to storing, retrieving and manipulating information stored in a relational database.

SQL is a standard language for Relational Database System (RDS).

All the Relational Database Management Systems (RDMS) like MySQL, Oracle, Sybase, Postgres , SQL Server etc. use SQL language.


Why SQL?

SQL is most popular because SQL offers the following advantages −


Database

The database is a collection of data (or information).


Relation database

A relational database is tables, where tables are related to one another in the database. This type of database allows data to be broken down into smaller, manageable, and logical units for better performance and maintenance.


Database management system

The software used to manage the database is called Database Management System (DBMS). For Example, Oracle, MySQL are the most popular commercial DBMS which used in different applications.


Standard query language (SQL)

SQL stands for Structured Query Language. SQL is a standard programming language which designed for storing, retrieving, managing or manipulating the data in a relational database management system.

we can do many more thing with SQL:


Data type

Data types use to enter value in the table.

Data type is divided into these categories:-

NUMERIC TYPE STRING TYPE DATE TYPE
Smallint Varchar Datetime
Int Char Date
Double Text --
Float Longblob --
Numeric Mediumblob --
Decimal Tinyblob --
Bigint blob year
binary bit year


MySQL String Data Types

CHAR(Size) It is used to specify a fixed-length string that contains numbers, letters, and special characters. Its size can be 0 to 255 characters.
VARCHAR(Size) It is used to specify a variable-length string that can contain numbers, letters, and special characters. Its size can be from 0 to 65535 characters.
BINARY(Size) It is same to CHAR() but stores binary byte strings.
VARBINARY(Size) It is same as VARCHAR() but stores binary byte strings.
TEXT(Size) It can hold a string that contains a maximum length of 255 characters.
TINYTEXT It can holds string with a maximum length of 255 characters.
MEDIUMTEXT It can holds string with a maximum length of 16,777,215.
SET( val1,val2,val3,....) SET is used to specify a string that can have 0 or more values.
BLOB(size) It is used for Binary Large Objects. It can hold up to 65,535 bytes.


MySQL Numeric Data Types

INT(size) It is used for the integer value.
FLOAT It is used to specify a floating-point number which has a decimal value.
BOOL It is specified Boolean values true and false. Zero is false, and nonzero values are true.


MySQL Date and Time Data Types

DATE It is used to specify a date in the format YYYY-MM-DD.
DATETIME(fsp) It is used to specify the date and time. the format is YYYY-MM-DD hh:mm:ss.
TIME(fsp) It is used to specify the time format. Its format is hh:mm:ss.
YEAR It s used to specify the year in four-digit format. Values allowed in four-digit from 1901 to 2155, and 0000.