SQL Programs
Introduction:
SQL is the heart of RDBMS. SQL is the language used for all operations in a
relational database. The minimum operations required for handling database are
creation of table, inserting data, updating data, deleting data, and retrieval of
data. In addition to this we require to control the access of data in a multi-user
database. In a multi-user database one user may want to secure his data from
another user, so adequate security should be provided. SQL is a very important
language because most of the RDBMS are using SQL as their language for
specifying operations. The syntax of SQL changes very little from one RDBMS
to another. SQL is also a very powerful language in the sense that most of the
operations in RDBMS can be performed using SQL. An important feature of
SQL is that it is a non-procedural language. In the procedural language we have
to give the complete procedure of doing the job. By using SQL one can create
table, insert data in the table, manipulate the data etc and can perform any
database operation. Since a lot of things can be done using SQL, these things
are grouped into different components according to their usage. They are as
follows:
Data Definition Language (DDL): It is a set of SQL commands used to create,
modify and delete database structure but not data. Examples of DDL command:
CREATE, ALTER, DROP, TRUNCATE.
Data Manipulation Language (DML): It is the area of the SQL that allows
changing data within the database. Using DML we can carry out operations
such as insertion, updating and deletion within the table. Examples of DML
command: INSERT, UPDATE, and DELETE.
Data Query Language (DQL): It is the component of the SQL statement that
allows getting data from the database or retrieving data from table and imposing
ordering upon it. It includes the SELECT statement. Examples of DQL
command: SELECT
1|Page
1. How to create database using a suitable name?
Query: Create database StudInfo;
2. How to create a table as well as column with different data type in database StudInfo
using a suitable name?
Query: Create table studDetail (StID int (10), StName varchar (20), AttPercentage float
(10));
3. How to insert values in the table studDetail?
Query: Insert into studDetail (StID, StName, AttPercentage) values (1, ‘John’, 70);
Insert into studDetail (StID, StName, AttPercentage) values (2, ‘James’, 60);
Insert into studDetail (StID, StName, AttPercentage) values (3, ‘Jacob’, 75.6);
Insert into studDetail (StID, StName, AttPercentage) values (4, ‘Jenny’, 65.03);
Insert into studDetail (StID, StName, AttPercentage) values (5, ‘Tony’, 55.5);
Output:
1.
2|Page
2.
3.
3|Page
4.
4|Page