| | apid | Theory you need to know! | eview | |
SQL Concepts :
SQL stands for Structured Query Language.
SQL statements cannot be executed without a DBMS.
SQL is used to perform various operations on the data in the database like creating, modifying & deleting tables, maintaining data integrity and retrieving the data.
For the RDBMS, an SQL program is just a single statement and is executed as a whole.
An SQL statement written on a Windows platform gives the same output on a Linux platform. Thus, SQL statements are platform independent however not necessarily database vendor independent.
SQL is a set level language as it operates upon a set of records. Languages that operate on one record at a time are known as record level languages.
SQL Environments :
Embedded and Dynamic SQL are the two types of SQL environments.
Through Embedded SQL, we can create programs that access the database through SQL statements embedded in it.
In Dynamic SQL, the SQL statements are not embedded in the program but are created dynamically.
If the names of the database objects change, it is easier to change the dynamic SQL statements as compared to the embedded SQL statements.
SQL Data Types :
SQL data types are the same across platforms. For example a INTEGER will occupy 4 bytes on both a Windows and a Linux platform.
The CLOB data type is used to store large amounts of formatted text like catalogs, brochures, books, etc.
The BINARY STRING data type can be used to store audio, video and image files. The data is stored in form of a sequence of bytes.
CHAR(length) is a fixed length character string data type.
BIT(length) data type can be used to store fixed length bit strings. However, BIT VARYING(length) can be used to store variable length bit strings.
A NULL value is used to represent unknown data.
A national character set literal is represented by preceding
it by N (example N'Jack').
If we want to include single quotes in a string constant, it is written as two consecutive single quotes.
Two strings can be concatenated using two consecutive bar characters ( || ). For example, ('Mr. ' || 'Roger ' || 'Abraham') returns the string Mr. Roger Abraham.
Symbolic constants allow us to easily access frequently required information. For example, CURRENT_DATE gives us the date and CURRENT_TIME gives us the current time.
The POSITION(string1 IN string2) function returns the starting position of string1 in string2.
TRY EXERCISES ON ABOVE THEORY
| |