Structured Query Language

Sep 27 • Notes • 3230 Views • No Comments on Structured Query Language

Structured Query language (SQL) is a standard language for making queries in relational database management packages such as SQL server, Ingress, Sybase, Oracle, etc. SQL  is a fourth generation language and it is very simple and powerful language because it uses compact, English- like statements and performs very complex jobs to access information from large sized database. The language was initially created by IBM and modified by various other software designers. 

Characteristics of SQL
The characteristics of SQL are as follows:
(a) SQL is oriented specifically around relational databases
(b) SQL commands can operate on several groups of tables as single objects.
(c) It processes any quantity of information , retrieved from these tables, as a single unit.
(d) SQL allows use of temporary tables.
(e) SQL is well suited to a client server environment, where the DBMS resides on a server and services the client’s requests.
(f) SQL provides a flexible transaction management.
(g) SQL allows users to create domains as objects in a schema.
(h) SQL allows one to specify constraints.
(i) Privileges can be granted or denied using SQL commands.

Advantages of SQL
One can use SQL commands for the following purposes:

Structured Query Language

SQL

(a) Creating, deleting, and modifying table structure
(b) Defining the relationships between two or more tables.
(c) Inserting data into tables
(d) Extracting data in meaningful ways, based on the table’s defined relationships
(e) Updating data
(f) Controlling the database

Types of SQL variations
SQL has two variations.
(a) Interactive SQL: The interactive SQL is used to operate directly on a database to produce output for desired purpose. In this form of SQL, a command is entered and executed. The output can be seen immediately.
(b) Embedded SQL: The embedded SQL consists of SQL commands put inside the programs which are written in other high level language . This method makes query system more powerful and efficient. The output of SQL commands in embedded SQL is “passed off ” to variables or parameters which are used by the program in which SQL commands are embedded.

Data types in SQL
Some of the common data types that are used in SQL are
(a)  CHAR(size):- A column is defined with a CHAR data type is allowed to store all types of characters which include letters- both uppercase and lower case such ad A,B,…..,Z and a,b,…..z, special characters like @#&$, etc. and numerals that are perceived by the numbers.
(b)
VARCHAR2(size):- This is similar to CHAR but can store variable sized string having maximum length determined by “size”.
(c)  NUMBER(p, s):- This is used to store variable length numeric data. The value of p determines the total number of digits possible to the left of decimal points. The second syllable s, determines the total number of digits possible to the right of decimal point.
(d) DATE:- This type of data is used to store date and time information. Default format is DD-MM-YY.
(e) LONG:- LONG data types stores variable length character strings containing up to 2 gigabytes size.

Below are some questions involving queries for better understanding

SQL command to create a table named “EMPLOYEE”.
Ans- create table employee (emp_id char(4), emp_name varchar2(20), design varchar2(10), doj date, basic number(8,2));

Insert the following data into the respective EMPLOYEE table. Emp_id:- 1001 Emp_name:- Ram Desig:- HR Doj:- 19th july 2000 Basic:- 20,000

Ans- insert into table employee (“1001”, “Ram”, “HR”, “19th July 2000”, ‘20000’);

Write the SQL code for creating the following table STUDENT.

Name

Null

Type

Stdid

Primary key

number(5)

Name

not null

varchar2(30)

Branch

not null

varchar2(10)

Ans- create table student (stdid number(5) primary key, name varchar2(30) not null, branch varchar2(10) not null);  

Types of SQL commands.
SQL commands can be classified into the following three types.
(a)  Data definition language commands: It is a part of SQL commands which consists of those commands that create objects in the database. Create, Drop and Alter are few commands of DDL language.
(b) Data manipulation language commands: It is the part of SQL which consists of a set of commands that determine which values are present in the tables at any given time.
(c)  Data control language commands:- It is another portion of SQL which allows definition of a security mechanism or scheme for protecting data from unauthorized access.                      

 You may also like to visit:

Important SQL questions and answers

Oureducation.in is the best source for your learning

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

« »