0% found this document useful (0 votes)
33 views

Lab Session 1

Lab session file of Software engineering affiliated to AKTU syllabus

Uploaded by

VAIBHAV KUSHWAHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Lab Session 1

Lab session file of Software engineering affiliated to AKTU syllabus

Uploaded by

VAIBHAV KUSHWAHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab Session – 01

OBJECT - Introduction to SQL

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.

SQL (Structured Query Language) is used to perform operations on the records stored in the database, such
as updating records, inserting records, deleting records, creating and modifying database tables, views, etc.

SQL is not a database system , but it is a query language. SQL uses certain command like create, drop,
insert, etc. to carry out required tasks.

These SQL command are mainly categorized into four categories as:

1. DDL - Data Definition Language.


2. DML - Data Manipulation Language.
3. DCL - Data Control Language.
4. TCL - Transaction Control Language.
5. DQL - Data Query Language.

1.Data Definition Language (DDL)

DDL changes the structure of the table like creating a table, deleting a table, altering a table, etc.
All the command of DDL are auto-committed that means it permanently save all the changes in the database.
Here are some command that comes under DDL.

a. CREATE : It is used to create a new table in the database or it’s object .


Syntax : CREATE TABLE table_name
{
Column_name 1 data_type[column 1 constraints(s)],
Column_name 2 data_type[column 1 constraints(s)],
……..
Column_name N data_type[column 1 constraints(s)],
PRIMARY KEY
};
b. DROP: It is used to delete both the structure and record stored in the table.
Syntax : DROP TABLE [ IF EXISTS]
table_1, table_2,……….. table_name N;

c. ALTER: It is used to alter the structure of the database. This change could be either to modify the
characteristics of an existing attribute or probably to add a new attribute
Syntax : ALTER TABLE table_name ADD column_name datatype[(size)].
ALTER TABLE table_name MODIFY column_name datatype[(size)]..

d. TRUNCATE: It is used to delete all the rows from the table and free the space containing the table.
..=Syntax : TRUNCATE TABLE table_name;

2. Data Manipulation Language (DML)

DML commands are used to modify the database. It is responsible for all form of changes in the
database.The command of DML is not auto-committed that means it can't permanently save all the changes
in the database. They can be rollback. Here are some command that comes under DDL.

a. INSERT: The INSERT statement is a SQL query. It is used to insert data into the row of a table.
Syntax : INSERT INTO TABLE_NAME
(col1, col2, col3,.... col N)
VALUES (value1, value2, value3, .... valueN);

b. UPDATE: This command is used to update or modify the value of a column in the table.
C= Syntax : UPDATE table_name SET [column_name1= value1,...column_nameN = valueN]

c. DELETE : It is used to remove one or more row from a table.


Syntax : DELETE FROM table_name[WHERE condition];

3. Data Control Language (DCL)

DCL includes commands such as GRANT and REVOKE which mainly deals with the right , permission and
other control of Database system. Here are some command that comes under DDL.
a. Grant: It is used to give user access privileges to a database.

b. Revoke: It is used to take back permissions from the user.

4. Transaction Control Language (TCL)

TCL commands can only use with DML commands like INSERT, DELETE, and UPDATE only.Here are
some command that comes under DDL.

a. COMMIT: Commit command is used to save all the transactions to the database.
Syntax: COMMIT;

b. ROLLBACK: Rollback command is used to undo transactions that have not already been saved to the
database.
Syntax: ROLLBACK;

c. SAVEPOINT: It is used to roll the transaction back to certain point without rolling back the entire
transaction.
Syntax: SAVEPOINT SAVEPOINT_NAME;

5. Data Query Language (DQL)

DQL is used to fetch data from the database. It uses only one command – SELECT.

a. SELECT: This is the same as the projection operation of relational algebra. It is used to select the
attribute based on the condition described by WHERE clause.
Syntax : SELECT expressions
FROM TABLES
WHERE conditions;

You might also like