0% found this document useful (0 votes)
54 views5 pages

Practical 4: To Create Given Table and Perform Different Tasks On The Table

The document describes creating a FACULTY table in a database and performing tasks on it. It creates the table, inserts values, and then performs 6 tasks: displaying distinct department names, updating a department code, deleting a row, displaying names starting with R, displaying names ending with N, and deleting a column. The tasks demonstrate using SELECT, UPDATE, DELETE, ALTER, and LIKE queries on the table.

Uploaded by

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

Practical 4: To Create Given Table and Perform Different Tasks On The Table

The document describes creating a FACULTY table in a database and performing tasks on it. It creates the table, inserts values, and then performs 6 tasks: displaying distinct department names, updating a department code, deleting a row, displaying names starting with R, displaying names ending with N, and deleting a column. The tasks demonstrate using SELECT, UPDATE, DELETE, ALTER, and LIKE queries on the table.

Uploaded by

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

PRACTICAL 4

AIM: To create given table and perform different tasks on the table.

The above table was created using queries:-

Queries:
To create a new table FACULTY.

mysql>USE FACULTY;

Database changed

mysql>CREATE TABLE FACULTY (EMP_ID INT,EMP_NAME VARCHAR(20),DEPT_NAME


VARCHAR(20),DEPT_CODE VARCHAR(20));

Query OK,0 rows affected(0.26 sec)

To insert values into the table FACULTY.

mysql> INSERT INTO FACULTY VALUES

(102,"HARRY","PHARMA","PHA"),(103,"MOHAN","COMPUTER","CSE"),(104,"RAMU","CIVIL","CE"),
(105,"SHYAM","COMPUTER","CSE"),(106,"GEETA","MECHANICAL","ME"),(107,"ARYAN","CHEMICAL","CH");

Query OK, 6 rows affected (0.11 sec)

Presented By: Shivam Roll Number:170102185


Task 1: Display distinct department names from the table.
Syntax: SELECT DISTINCT DEPT_NAME FROM FACULTY;

Query:

Task 2: Update Department code of PHARMA from PHA to PHAR.


Syntax: UPDATE FACULTY SET DEPT_CODE=’’PHAR” WHERE EMP_ID=102;

Query:

Presented By: Shivam Roll Number:170102185


Task 3: Delete 5th row from the table.
Syntax: DELETE FROM FACULTY WHERE EMP_ID=105;

Query:

Task 4: Display names of all employees starting with ‘R’.


Syntax: SELECT EMP_NAME FROM FACULTY WHERE EMP_NAME LIKE ‘R%’;

Query:

Presented By: Shivam Roll Number:170102185


Task 5: Display names of all the employees ending with ‘N’.
Syntax: SELECT EMP_NAME FROM FACULTY WHERE EMP_NAME LIKE ‘%N’;

Query:

Task 6: Delete DEPT_CODE completely from the table.


Syntax: ALTER TABLE FACULTY DROP DEPT_CODE;

Query:

Presented By: Shivam Roll Number:170102185


Presented By: Shivam Roll Number:170102185

You might also like