SQL: Background, Basic Structure

  • SQL stands for Structured Query Language. It is used for storing and managing data in relational database management system (RDMS).
  • It is a standard language for Relational Database System. It enables a user to create, read, update and delete relational databases and tables.
  • All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL as their standard database language.
  • SQL allows users to query the database in a number of ways, using English-like statements.

Rules:

  • Structure query language is not case sensitive. Generally, keywords of SQL are written in uppercase.
  • Statements of SQL are dependent on text lines. We can use a single SQL statement on one or multiple text line.
  • Using the SQL statements, you can perform most of the actions in a database.
  • SQL depends on tuple relational calculus and relational algebra.

SQL process:

  • When an SQL command is executing for any RDBMS, then the system figure out the best way to carry out the request and the SQL engine determines that how to interpret the task.
  • In the process, various components are included. These components can be optimization Engine, Query engine, Query dispatcher, classic, etc.
  • All the non-SQL queries are handled by the classic query engine, but SQL query engine won’t handle logical files.

SQL Datatype

  • SQL Datatype is used to define the values that a column can contain.
  • Every column is required to have a name and data type in the database table.

Datatype of SQL:

dbms-sql-datatype.png

1. Binary Datatypes

There are Three types of binary Datatypes which are given below:

Data Type Description
binary It has a maximum length of 8000 bytes. It contains fixed-length binary data.
varbinary It has a maximum length of 8000 bytes. It contains variable-length binary data.
image It has a maximum length of 2,147,483,647 bytes. It contains variable-length binary data.

2. Approximate Numeric Datatype :

The subtypes are given below:

Data type From To Description
float -1.79E + 308 1.79E + 308 It is used to specify a floating-point value e.g. 6.2, 2.9 etc.
real -3.40e + 38 3.40E + 38 It specifies a single precision floating point number

3. Exact Numeric Datatype

The subtypes are given below:

Data type Description
int It is used to specify an integer value.
smallint It is used to specify small integer value.
bit It has the number of bits to store.
decimal It specifies a numeric value that can have a decimal number.
numeric It is used to specify a numeric value.

4. Character String Datatype

The subtypes are given below:

Data type Description
char It has a maximum length of 8000 characters. It contains Fixed-length non-unicode characters.
varchar It has a maximum length of 8000 characters. It contains variable-length non-unicode characters.
text It has a maximum length of 2,147,483,647 characters. It contains variable-length non-unicode characters.

5. Date and time Datatypes

The subtypes are given below:

Datatype Description
date It is used to store the year, month, and days value.
time It is used to store the hour, minute, and second values.
timestamp It stores the year, month, day, hour, minute, and the second value.

 

One thought on “SQL: Background, Basic Structure

Leave a Reply

error: Content is protected !!
%d bloggers like this: