You are on page 1of 9

ABHISHEK

KUMAR
SINGH
19CSE001

PRACTICAL FILE OF
Python Practicals

GANGA INSTITUTE OF TECHNOLOGY


AND
MANAGEME
NT (2020-2021)
Submitted To Submitted By

RUCHI MAAM ABHISHEK KUMAR


SINGH Professor (CSE)
19CSE001 GITAM, Kablana

3rd Sem 


PROGRAM-1
AIM:- Creating of a database and writing SQL
queries to retrieve information from the database.

CREATE-

CREATE TABLE Persons (

Rollnum int,

LastName varchar(255),

FirstName varchar(255),

Address varchar(255),

City varchar(255)

);

OUTPUT- desc Persons;

Retrieve:

alter table Persons modify(

city varchar(500)

);

OUTPUT- desc Persons;

PROGRAM-2
AIM:- Performing Insertion, Deletion, Modifying Altering,
Updating and Viewing records based on conditions.
CREATE- Insertion
insert into Persons
(Rollnum ,LastName,FirstName ,Address ,City )

values (50 ,'SINGH','ABHISHEK','NAJAFGARH KE DON' ,


'NEW DELHI')

OUTPUT- SELECT * FROM PERSONS

CREATE- Deletion
delete from PERSONS

OUTPUT-

CREATE- Modifying Altering. OUTPUT-desc Persons;


ALTER TABLE PERSONS
ADD Email varchar(255);

CREATE-Updating.
UPDATE PERSONS
SET FirstName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE Rollnum = 50;

OUTPUT-SELECT * FROM PERSONS

CREATE-Viewing records based on conditions.


SELECT FIRSTNAME
FROM PERSONS
WHERE ROLLNUM = 50 ;
OUTPUT-

PROGRAM-3
AIM:- Creation of Views, Synonyms, Sequence, Indexes,
Save point.
CREATE- Creation of Views.
VIEW: A view is simply the representation of a SQL statement that is stored in memory so
that it can easily be re-used. Its also referred as logical table.
SYNTAX: CREATE OR REPLACE VIEW <view name> AS < select statement >

SQL> CREATE VIEW address AS


SELECT firstName, lastName
FROM persons
WHERE City = ‘UP';
OUTPUT-SELECT * FROM address;

#Creation of Synonyms.
SYNONYM: A synonym is an alias or alternate name for a table, view, sequence, or other
schema object. They are used mainly to make it easy for users to access database objects
owned by other users.

* Create a synonym for a table created by other user.


SYNTAX:CREATE OR REPLACE SYNONYM <synonym_name> FOR <object_name>

SQL> CREATE SYNONYM EMP FOR SP.EMPLOYE;

#Creation of Sequence.
SEQUENCE: A sequence is a database object from which multiple users may generate
unique integers. User can use sequences to automatically generate primary key values

* Create a sequence to generate unique value for empid eld in the employee table while
inserting

SQL> CREATE SEQUENCE EMP_SEQ START WITH 1000 INCREMENT BY 1 NOCACHE


NOCYCLE

OUTPUT: Sequence Created.


.

fi

#Creation of Indexes.
INDEXES: Database system uses indexes to avoid the need for large-table, full-table scans
and disk sorts, which are required when the SQL optimizer cannot nd an ef cient way to
service the SQL query.
SYNTAX: CREATE INDEX <INDEX-NAME>ON <table-name(attribute)

*Create index for city attribute in employee table.


SQL> CREATE INDEX EMP_INDEX ON EMP(CITY);

OUTPUT:
Index Created.

fi
fi
>

PROGRAM-4
AIM:- Creating an Employee database to set various
constraints.

You might also like