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

Labwork DBMS

Uploaded by

sayan2017nimtala
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Labwork DBMS

Uploaded by

sayan2017nimtala
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

DBMS LABWORK

Name: Intekhab Alam Khan


Roll: GCECTB-R21-1013
Year: 3rd Year ( 5th Sem)
Dept: Ceramic Technology
ASSIGNMENT-1
Creating a table, inserting values, and displaying them:

Inserting more values into the table:


Displaying specific Columns:

Displaying specific Columns using where clause:


ASSIGNMENT-2
Sorting Rows:

Updating Rows using where clause:

Eliminating Duplicate Rows:


ASSIGNMENT-3
Adding new columns to the table:

Delete specific Rows:


Update all rows:

Renaming a Table:

Dropping Specific Column:


Renaming Columns:
ASSIGNMENT-4
LIKE Statement: This operator is used in a where clause to search for a specific pa ern in a
column.

Syntax: SQL> select * from Table_name where column_name LIKE ‘_%’ ;

Using OR:
Syntax- SQL> select * from Table_name where column_name =value OR column_name2 like ‘_%’;

Using AND:
Syntax- SQL> select * from Table_name where column_name =value AND column_name2 like ‘_%’;
Using Between:

Aggregate Function- An SQL aggregate func on calculates a set of values and returns a single
value. For example, an average func on (AVG) takes a list of values and returns the average.

Syntax: SQL> select AVG(column_name) “AVERAGE” from Table_name;


ASSIGNMENT-5
SQL JOIN Keyword:
A JOIN clause is used to combine rows from two or more tables, based on a related column
between them.
Here are the different types of the JOINs in SQL:
(INNER) JOIN: Returns records that have matching values in both tables.
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records
from the right table.
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records
from the left table.
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right
table.
Syntax: SQL> select column_name from table1 INNER JOIN table2 ON
table1.column_name=table2.column_name;
GRANT & REVOKE
Create a new user and grant permission.

Opening a table of parent user from new user:

Revoking Permission
ASSIGNMENT-6
A Primary key is a unique column we set in a table to easily identify and locate data in
queries. A table can have only one primary key.
The primary key column has a unique value and doesn’t store repeating values. A Primary
key can never take NULL values. For example, in the case of a student when identification
needs to be done in the class, the roll number of the student plays the role of Primary key.
Syntax:
CREATE TABLE tableName (
col1 int NOT NULL,
col2 varchar(50) NOT NULL,
col3 int,
…………….
PRIMARY KEY (col1)
);

A Foreign key is beneficial when we connect two or more tables so that data from both
can be used parallelly. The table which contains the foreign key is often called the child table,
and the table whose primary key is being referred by the foreign key is called the Parent
Table.
Syntax:
CREATE TABLE childTable (
col1 int NOT NULL,
col2 int NOT NULL,
col3 int,
………...
PRIMARY KEY (col1),
FOREIGN KEY (col3) REFERENCES parentTable(parent_Primary_key)
);

You might also like